algorithm

An algorithm is a specific set of actions that when carried out on data (input) of the allowed type will produce an output. This is the meaning in mathematical discourse. There are related meanings in use:

Example 1 One might express a simpleminded algorithm for calculating a zero of a function $f(x)$ using Newton’s Method by saying

“Start with a guess $x$ and calculate $x-\dfrac{f(x)}{f'(x)}$ repeatedly until $f(x)$ gets sufficiently close to 0 or the process has gone on too long.”

One could spell this out in more detail this way:

  1. Choose an accuracy $\epsilon$, the maximum number of iterations $N$, and a guess $s$.
  2. Let $n=0$.
  3. If $|f'(s)|<\epsilon$ then stop with the message “derivative too small”.
  4. Replace $n$ by $n+1$.
  5. If $n>N$, then stop with the message “too many iterations”.
  6. Let $r=s-\dfrac{f(s)}{f'(s)}$.
  7. If $|f(r)|<\epsilon$ then stop; otherwise go to step 3 with $s$ replaced by $r$.

Observe that neither description of the algorithm is in a programming language, but that the second one is precise enough that it could be translated into most programming languages quite easily. Nevertheless, it is not a program.

Citations: (77), (98).

Remark 1 It is the naive concept of abstract algorithm given in the preceding examples that is referred to by the word “algorithm” as used in mathematical discourse, except in courses and texts on the theory of algorithms. In particular, the mathematical definitions of algorithm that have been given in the theoretical computing science literature all introduce a mass of syntactic detail that is irrelevant for understanding particular algorithms, although the precise syntax may be necessary for proving theorems about algorithms, such as Turing’s theorem on the existence of a noncomputable function.

Example 2 One can write a program in Pascal and another one in C to take a list with at least three entries and swap the second and third entries. There is a sense in which the two programs, although different as programs, implement the “same” abstract algorithm.

The following statement by Pomerance [1996] (page 1482) is evidence for this view on the use of the word “algorithm”: “This discrepancy was due to fewer computers being used on the project and some ‘down time’ while code for the final stages of the algorithm was being written.” Pomerance clearly distinguishes the algorithm from the code.

Remark 2 Another question can be raised concerning Example 2. A computer program that swaps the second and third entries of a list might do it by changing the values of pointers or alternatively by physically moving the entries. (Compare the discussion under alias). It might even use one method for some types of data (varying-length data such as strings, for example) and the other for other types (fixed-length data). Do the two methods still implement the same algorithm at some level of abstraction?

See also overloaded notation.

Acknowledgments: Eric Schedler, Michael Barr.

Pages 9–11 of the book (PDF).