1 What Is an Algorithm?
An algorithm is a finite, ordered set of clear instructions that transforms one or more inputs into an output. The word comes from the name of the 9th-century Persian mathematician al-Khwārizmī. Algorithms appear everywhere: a recipe, a bus timetable, and a sorting app all follow algorithmic logic.
- Algorithms must be finite — they must eventually stop.
- Each step must be unambiguous — only one valid interpretation.
- They must be general — able to handle a range of valid inputs.
A key property is determinism: given the same input, an algorithm always produces the same output. This distinguishes it from a guess or a random process.