What Is an Algorithm?
What Euclid, IKEA instructions, and Google search have in common — all three are algorithms.
You follow algorithms every day — crossing the street, making coffee, unlocking your phone. But what turns a casual sequence of steps into something a computer can execute?
The name "algorithm" traces back to the Persian scholar Al-Khwarizmi, who lived in the 9th century — the word itself emerged in the 12th century through the Latin translation of his works. In this article, you will learn what distinguishes a real algorithm from vague instructions — and why this concept is the foundation of every AI system.
The Algorithm: A Precise Sequence of Steps
Algorithm
The IKEA analogy breaks at an important point: IKEA instructions contain visual ambiguity — which hole? Which orientation? A real algorithm cannot have such ambiguity. This is the core insight: algorithms demand MORE precision than even good human instructions.
Let's see this in a concrete example — Euclid's algorithm. It calculates the greatest common divisor (GCD) of two numbers. Instead of trying all possible divisors, you stubbornly follow these steps:
Example: Euclid's GCD Algorithm (252, 105)
Common Misconception: Algorithm = Program
Recipe vs. Algorithm: Why Precision Matters
A cooking recipe says: "Heat butter in a pan, add eggs, stir gently until done." This works for a human — but a robot would fail. How much butter? What temperature? What does "gently" mean? The gap between recipe and algorithm is the gap between natural language and formal language.
"Heat butter, add eggs, stir gently until done." — Works because humans can improvise. Vague terms like "a pinch of salt" or "golden brown" assume experience.
"Heat 15g butter at 120°C for 90 seconds. Pour in 150ml beaten egg mixture. Move spatula in 3cm circles at 1 revolution per second. Stop when internal temperature reaches 74°C." — Every step is measurable and unambiguous.
When you tell a human "sort 5, 2, 8, 1", they just do it. An algorithm must specify HOW: compare the first two numbers, swap if needed, move to the next pair, repeat until no swaps are needed. The human uses intuition; the algorithm uses explicit rules. Both reach the same result — but only the algorithm can be given to a machine.
Correct Does Not Mean Good
Interactive: Bubble Sort
The article says: "Compare the first two numbers, swap if needed, move to the next pair." Here you can step through exactly that — and see how Bubble Sort sorts the array [5, 2, 8, 1, 4].
Interactive: The Treasure Robot (Knapsack Problem)
A robot has to pack the most valuable treasures into a backpack with limited room. Just greedily grabbing the priciest ones first often backfires. Here you can see how an algorithm cracks it: it fills a table cell by cell — each cell is the best decision (take a treasure or leave it) — and at the end reads the optimal backpack backwards out of the table.
From Al-Khwarizmi to Turing: 4,000 Years of Algorithmic Thinking
Algorithmic thinking is not a modern invention. The core idea — breaking problems into repeatable, mechanical steps — is over 4,000 years old. Five milestones mark the journey:
The word itself tells the story: Al-Khwarizmi → Latinized to "Algoritmi" → became "algorithm" in European languages. When you say "algorithm," you are literally invoking a 9th-century Persian scholar.
Deep Dive: Turing's Boundary of Computability
Synthesis: From the Abacus to Artificial Intelligence
Key Takeaways
Quiz: Understanding Algorithms
Checkpoint: Test Your Knowledge
- Name the three mandatory properties of an algorithm and explain each in one sentence.
- Why would a robot fail at the recipe "heat butter, add eggs, stir gently"? What would need to change to make it an algorithm?
- Where does the word "algorithm" come from? Name the historical origin and at least two other milestones in the history of algorithms.