# Difference between algorithm and procedure

I came to know that the important difference between algorithm and procedure is that the algorithm halts and procedure doesn't halts(stops). But i am not able to understand the concept. Please can any one explain with the example?

Let me cite the classic -- D.E. Knuth's "The Art of Computer Programming", 3ed (1997).

Some terminology first.

The modern meaning for algorithm is quite similar to that of recipe, process, method, technique, procedure, routine, rigmarole, except that the word "algorithm" connotes something just a little different.

Note: the bold face is mine. Then Knuth goes on:

A procedure that has all of the characteristics of an algorithm except that it possibly lacks finiteness may be called a computational method.

It turns out that one of the earliest examples of a computational method belongs to Euclid:

Euclid originally presented not only algorithm for the greatest common divisor of numbers, but also a very similar geometrical construction for the "greatest common measure" of the lengths of two line segments; this is a computational method that does not terminate if the given lengths are incommensurable. Another example of a nonterminating computational method is a reactive process, which continually interacts with its environment.

It seems that by the second case Knuth meant operating systems, web-servers and so on, i.e. the programs that are supposed to run "forever", but do something useful along the way.

What most people say is that a procedure is something which may go on and on or may stop/halt but an algorithm is some thing that is well defined and will stop and give output. Moreover, an algorithm is something much deep and theoretically proven. People do write new algorithms but they provide mathematical proofs for it. Anyone can write a procedure to do a task but it may or may not be a well defined and proven algorithm. Lastly, I personally believe, the logic that does the work most efficiently is what's needed.

• What about algorithms that are terminated to give partial output, because otherwise they would run forever? – Evil Apr 24 '16 at 0:51
• Halting problem! How do you know an algorithm will stop? – innisfree Apr 24 '16 at 6:36