What is an algorithm?
An algorithm is a set of step-by-step instructions for solving a problem or completing a task. Computers follow algorithms to do everything from sorting lists and finding routes to recommending videos.
Algorithms are not only for computers. A recipe, the directions for building furniture and the method for long division are all algorithms.
What makes a good algorithm
An algorithm should be clear and precise, so each step has only one meaning. It should also finish after a limited number of steps and produce the correct result.
Computer scientists also care about efficiency: how much time and memory an algorithm needs as the amount of data grows.
Examples
Sorting algorithms, such as merge sort and quicksort, arrange items in order.
Search algorithms find information. Binary search quickly finds a value in a sorted list by repeatedly halving the search area.
Map apps use pathfinding algorithms to find the shortest or fastest route.
Origin of the word
The word algorithm comes from the name of the Persian mathematician Muhammad ibn Musa al-Khwarizmi, who lived in the 800s. His works helped introduce Hindu-Arabic numerals and algebra to Europe.
Euclid's method for finding the greatest common divisor of two numbers, from around 300 BC, is one of the oldest known algorithms still in use.