Search⌘ K

What is an Algorithm?

Explore the definition and characteristics of an algorithm, including a practical example and its historical background. Understand how algorithms are precise, unambiguous instructions designed to solve specific problems, and discover the origins of the term from early mathematical practices.

Algorithm

An algorithm is an explicit, precise, unambiguous, mechanically-executable sequence of elementary instructions, usually intended to accomplish a specific purpose. For example, here is an algorithm for singing that annoying song “99 Bottles of Beer on the Wall” for arbitrary values of 99:

Algorithm


BottlesofBeer(n)    For in down to 1Sing “i bottles of beer on the wall, i bottles of beer,Sing “Take one down, pass it around, i1 bottles of beer on the wall.Sing “No bottles of beer on the wall, no bottles of beer,Sing “Go to the store, buy some more, n bottles of beer on the wall.\underline{Bottles of Beer(n)} \\ \space\space\space\space For\space i ←n\space down\space to\space 1\\ \hspace{1cm} Sing\space “i\space bottles\space of\space beer\space on\space the\space wall,\space i\space bottles\space of\space beer,” \\ ...