0 like 0 dislike
102 views
What is an algorithm?
| 102 views

0 like 0 dislike

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:

- The algorithm may be implemented as a program in a computer language. This program may itself be referred to as the algorithm.
- In texts on the subject of algorithm, the word may be given a mathematical definition, turning an algorithm into a mathematical object (compare the uses of proof).

Example

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-\frac{f(x)}{f^{\prime}(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 $\left|f^{\prime}(s)\right|<\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-\frac{f(s)}{f^{\prime}(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.

by Diamond (57,849 points)

0 like 0 dislike
0 like 0 dislike
0 like 0 dislike
1 like 0 dislike
0 like 0 dislike
1 like 0 dislike
1 like 0 dislike
1 like 0 dislike
1 like 0 dislike