What Is an Algorithm?
What Euclid, IKEA instructions, and Google search have in common — all three follow fixed sequences of steps.
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 from the Latin translations of his works in the 12th century. 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
Definition
Algorithm
Analogy
Definition
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 one rule: divide the larger number by the smaller one, then the divisor by the remainder, until the remainder is 0:
Example: Euclid's GCD Algorithm (252, 105)
- 1. 252 ÷ 105 = 2, remainder 42
- 2. 105 ÷ 42 = 2, remainder 21
- 3. 42 ÷ 21 = 2, remainder 0
- 4. Remainder is 0 → the last divisor (21) is the GCDin just 3 steps, over 2,300 years old
Caution
Common Misconception: Algorithm = Program
An algorithm is the abstract logic — a program is one concrete implementation in a specific programming language. The same algorithm (e.g., Euclid's GCD) can be written in Python, Java, or executed by hand on paper. The algorithm exists independently of any programming language.
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, 4", 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.
Note
Correct Does Not Mean Good
Two algorithms can both correctly sort a list, but one might take 10 steps and the other 10,000. Correctness and efficiency are separate qualities. A correct algorithm solves the problem — a good algorithm solves it fast.
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 list [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 most valuable per kilo first often backfires. Here you can see how an algorithm cracks it: it fills a table cell by cell — each cell stores the best value (take a treasure or leave it) — and at the end reads the optimal backpack backwards out of the table.
From Babylon 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 almost 4,000 years old. Five milestones mark the journey:
Babylonian Clay Tablets
~1800 BC
Step-by-step procedures for calculating areas, volumes, and square roots.
Euclid
~300 BC
The GCD algorithm in "Elements" — according to Donald Knuth, the oldest nontrivial algorithm that has survived to the present day.
Al-Khwarizmi
~820 AD
Persian mathematician whose book "Kitab al-Jabr" gave us the word "algebra" and whose Latinized name "Algoritmi" became "algorithm."
Ada Lovelace
1843
Her algorithm for Bernoulli numbers on Babbage's Analytical Engine is often called the first published computer program.
Alan Turing
1936
Formalized what "computable" means. Proved that some problems are fundamentally unsolvable by any algorithm.
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.
In 1936, Alan Turing proved that certain problems are fundamentally unsolvable — no matter how clever the algorithm. The most famous example is the halting problem: there is no algorithm that can predict, for every possible program, whether it will eventually halt or run forever. Turing drew the absolute boundary of algorithmic thinking.
Note
Synthesis: From the Abacus to Artificial Intelligence
From Babylonian scribes to Persian mathematicians to modern computer scientists — the algorithm is one of humanity's oldest mental tools for turning chaos into repeatable, verifiable solutions.
And this is where AI connects: every neural network training loop, every search engine ranking, every recommendation is an algorithm. Without this concept, AI remains a black box.
Note
Key Takeaways
- An algorithm is a finite, unambiguous sequence of instructions. In classical algorithms, the same input always produces the same output.
- Three properties characterize classical algorithms: determinism, finiteness, unambiguity. Randomized algorithms use randomness but remain precisely defined in every step.
- An algorithm is not the same as a program. The algorithm is the abstract logic; the program is a concrete implementation.
- The gap between recipe and algorithm is the gap between human improvisation and machine precision.
- Algorithmic thinking is almost 4,000 years old — from Babylonian clay tablets through Al-Khwarizmi to Turing's proof of the limits of computability.
Check
Quiz: Understanding Algorithms
Which of the following is NOT a core property of a classical algorithm?
Select one answer
1. Which of the following is NOT a core property of a classical algorithm?
2. A robot receives the instruction: "Heat the pan until it's hot enough." What must change for this to become an algorithmic step?
3. You apply Euclid's GCD algorithm to the numbers 48 and 18. What is the first step?
4. Two sorting algorithms both produce the correct result. A takes 100 steps, B takes 10,000. Which statement is correct?
Check
Checkpoint: Test Your Knowledge
Can you explain this in your own words? Tick what you've got.
0 of 3 done