Computer scientists describe how fast an algorithm is with Big-O notation: O(log n), O(n), O(n log n), O(n²). Behind the letters is a simple question: when the input gets twice as big, what happens to the work? Here four real algorithms run on lists of up to 4,096...
Interactive
Euclid’s Algorithm: Find the Greatest Common Divisor by Cutting Off Squares
What is the largest number that divides both 48 and 18? You could list every divisor of each and compare, or you could use a method that is more than 2,000 years old and needs only a handful of steps. Euclid's algorithm has a picture behind it: cut the largest...
The Sieve of Eratosthenes: Cross Out the Multiples, Keep the Primes
Over two thousand years ago, the Greek scholar Eratosthenes found a simple way to list prime numbers: write down the numbers, then cross out the multiples of each prime in turn, and whatever is never crossed out is prime. Step through his sieve on the numbers up to...
Breadth-First vs Depth-First Search: Two Ways Through the Same Maze
A maze can be searched in two classic ways: breadth-first, which tries every cell one step away, then every cell two steps away, and so on; or depth-first, which follows one corridor as far as it goes before backing up. Watch both work through the same maze side by...
The Tower of Hanoi: Solve It by Hand, Then Watch Recursion Do It
The Tower of Hanoi has one simple rule: move the whole tower to another peg, one disc at a time, and never put a larger disc on a smaller one. Solve it by hand first, then watch a computer solve it with recursion, a method in which a problem is solved by solving a...
The Travelling Salesman Problem: Find the Shortest Round Trip
A travelling salesman has to visit every city on the map once and then return home. In which order should he go to keep the trip as short as possible? Plan your own route, then compare it with a simple rule of thumb and with the true shortest route, found by checking...
The Birthday Paradox: Why 23 People Are Enough for a Shared Birthday
How many people must be in a room before it is more likely than not that two of them share a birthday? Most people guess something large, but the real answer is 23. Fill rooms with random birthdays, watch the matches appear, and run a thousand rooms to see the maths...
Binary, Decimal and Hex: Flip Eight Bits and Watch the Number Change
Every number inside a computer is stored as a row of bits, each one either on or off. Flip the eight bits below and watch the same value appear in binary, decimal and hexadecimal at once, with the sum of place values that connects them. Then take the challenge: build...
Boolean Logic Gates: Interactive Truth Table Builder
Logic gates are the fundamental building blocks of every computer ever made. Every decision your device takes — from checking a password to rendering a pixel — ultimately comes down to billions of these tiny circuits asking simple true-or-false questions. In this...
Caesar Cipher: Encode and Decode Secret Messages
The Caesar cipher is one of the oldest encryption tricks in the book — legend has it Julius Caesar used it to send secret military messages over 2,000 years ago. The idea is beautifully simple: shift every letter in your message a fixed number of steps along the...
Binary Search: Find Numbers Fast in a Sorted List
Have you ever wondered how a computer can find one record among millions in a fraction of a second? The secret is binary search — an elegant algorithm that works on any sorted list by repeatedly cutting the remaining possibilities in half. Instead of checking every...
Sorting Algorithms Visualised: Bubble, Selection & Insertion Sort Side by Side
Have you ever wondered how a computer decides to put things in order? There are many different sorting algorithms, and they all reach the same sorted result by taking very different routes. In this demo you can watch three classic algorithms — bubble sort, selection...












