A computer program is a complete product that allow the user to accomplish some set of related tasks. A media player, a word processor, a game, etc. are all programs that have many related functions for some specific task or set of tasks.
An algorithm is a set of instructions and logic that accomplishes some goal. They can be very simple or very complex. They typically take some data, process it, and then return some result.
A simple algorithm might be one that takes a list of cities and tells you which two are the closest. It’s a simple calculation with a simple dataset.
A more complex algorithm might be one that takes a list of online shopping profiles, analyzes buying patterns, then recommends products to other shoppers with similar buying patterns.
A typical computer program is made of many algorithms that are each responsible for a different task within that program.
Algorithms are much, much older than computers (the word comes from the name of a 9th-century Persian mathematician). Simply put, an algorithm is just a set sequence of instructions to solve a problem or perform some kind of computation. Lots of the pen-and-paper math done in school, like long division, could be described as algorithms.
These days the “algorithms” most people are talking about are the recommendation systems used by online stores, social media, internet marketers, etc. E.g. YouTube takes your viewing history and puts that into an algorithm that recommends other videos for you to watch.
An algorithm is a sequence of rules that guarantees a particular outcome (eg, sorting a list correctly). It can be implemented in any reasonably complete programming language.
A computer program is a sequence of instructions in a particular programming language. It may accomplish something, or nothing. It may terminate, or it may continue until the sun explodes. It is its own lawless thing.
When you design an algorithm you don’t need to describe it using computer code at all. You could describe it in purely mathematical or logical terms.
Then, if you want to make a computer carry out the steps of the algorithm, you could use whatever programming language you like. You could imagine an algorithm being implemented in Python, in C++, in JavaScript, etc – if the same underlying logic is being followed in each, you’d have multiple computer programs but still only one algorithm.
An algorithm is a set of steps to follow in a given situation.
The term “computer program” is usually reserved for a complete, usable product.
A computer program utilizes, among other things, various algorithms to do what it’s supposed to do, i.e. algorithms are one of the building blocks of computer programs.
Bear in mind that an algorithm doesn’t necessarily need to refer to something related to programming. For example, a cooking recipe can also be an algorithm. It’s just a set of instructions.
An algorithm is a set of instructions that are designed to achieve some goal. A recipe for chicken soup is an algorithm for making chicken soup, for example. In this case, the thing executing the algorithm is a person. Software is also a set of instructions, for example, an mp3 player is the set of all the instructions necessary for playing an mp3 file. In software, the thing executing the instructions is the computer.
A computer program typically consists of many algorithms, but it’s also possible to write a program that is just a single algorithm doing its job and terminating. In other words, usually a computer program is like an entire restaurant that not only makes chicken soup, but many other food algorithms, and even has waiter algorithms running around delivering the food, but a computer program can also be just one guy with a street stand making nothing but chicken soup.
Latest Answers