Algorithm

An algorithm is a recipe: a finite, unambiguous list of steps that takes some input and produces the right output every time. Long division is an algorithm; so is the method you'd use to look up a word in a dictionary. The same problem often has many algorithms, and they can differ enormously in efficiency — how the work grows as the input gets bigger.

Searching a sorted list is the classic example. Checking every entry in turn takes, on average, half a million steps for a million items. Binary search — jump to the middle, throw away the half that can't contain your target, repeat — needs about twenty. Same answer, wildly different cost. That scaling behaviour, not raw speed, is what computer scientists mean when they compare algorithms, and it usually depends on choosing the right data structure to hold the data.

hierarchy prerequisite related

See the full map →