Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

t\'s said that a program include algorithms, however if we refer to their defini

ID: 649291 • Letter: T

Question

t's said that a program include algorithms, however if we refer to their definition, an algorithm is a sequence of instructions written to perform a specified task and a computer program is also a sequence of instructions to perform a (some) tasks with computer.

Then what make a program different than an algorithm? is it a type of algorithm too?

In fact, I look for some formal definitions for an algorithm and a computer program so I can distinguish them from each other or identify algorithms within a program.

Update:I have noticed in Wikipedia by an informal definition (at least syntactically) any program is an algorithm.

An informal definition could be "a set of rules that precisely defines a sequence of operations." which would include all computer programs, including programs that do not perform numeric calculations. Generally, a program is only an algorithm if it stops eventually.

Explanation / Answer

Ultimately, the difference is one of perspective. A program is a program: a sequence of statements in some language, perhaps a programming language or machine-level instructions. Algorithms are usually described at a higher level than machine instructions or programming language statements but just how high a level is rather flexible. For example, in some circumstances, "Sort the array, then look at the kth element" is a perfectly good description of an algorithm for finding the kth largest object in an array; in other circumstances, you might want to specify much more detail about how the sorting takes place.

As you say, an algorithm is something like "a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer." So, literally speaking, every program is an algorithm. Usually, though, we speak of programs implementing algorithms. Usually, when describing an algorithm, we avoid the low-level detail of exactly how things are implemented, assuming that a competent programmer would be able to implement it in the langauge of their choosing.