What Is an Algorithm?

What Euclid, IKEA instructions, and Google search have in common — all three are algorithms.

Fundamentals 12 min Beginner May 3, 2026

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

AnalogyDefinition
An algorithm is like an IKEA assembly manual: numbered steps, defined parts (input), and a guaranteed result (output). Each step says exactly which screw goes where. But the manual itself does not build anything — it only describes what needs to be done.

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)

1
252 ÷ 105 = 2, remainder 42
2
105 ÷ 42 = 2, remainder 21
3
42 ÷ 21 = 2, remainder 0
4
Remainder is 0 → GCD = 21 (in just 3 steps, over 2,300 years old)

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.

Recipe (for humans)

"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.

Algorithm (for machines)

"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

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 array [5, 2, 8, 1, 4].

5
2
8
1
4
Step 1 / 11Starting position: The unsorted array [5, 2, 8, 1, 4]. Bubble Sort compares adjacent elements and swaps them if they are in the wrong order.

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:

~2000 BC
Babylonian Clay Tablets Step-by-step procedures for calculating areas, volumes, and square roots.
~300 BC
Euclid The GCD algorithm in "Elements" — arguably the first documented algorithm with a termination proof.
~820 AD
Al-Khwarizmi Persian mathematician whose book "Kitab al-Jabr" gave us the word "algebra" and whose Latinized name "Algoritmi" became "algorithm."
1843
Ada Lovelace Wrote the first algorithm intended for machine execution (Bernoulli numbers on Babbage's Analytical Engine).
1936
Alan Turing 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.

Synthesis: From the Abacus to Artificial Intelligence

From Babylonian scribes to Persian mathematicians to modern computer scientists — the algorithm is humanity's oldest tool 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.

Key Takeaways

  1. An algorithm is a finite, unambiguous sequence of instructions. In classical algorithms, the same input always produces the same output.
  2. Three properties characterize classical algorithms: determinism, finiteness, unambiguity. Randomized algorithms use randomness but remain precisely defined in every step.
  3. An algorithm is not the same as a program. The algorithm is the abstract logic; the program is a concrete implementation.
  4. The gap between recipe and algorithm is the gap between human improvisation and machine precision.
  5. Algorithmic thinking is over 4,000 years old — from Babylonian clay tablets through Al-Khwarizmi to Turing's computability proof.

Quiz: Understanding Algorithms

Question 1 / 4
Not completed

Which of the following is NOT a core property of a classical algorithm?

Select one answer
Answer Key: 1) B · 2) B · 3) B · 4) B

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.