Growth rates: who wins in the long run
Big-O notation throws away the constant factors and keeps only the shape of the growth. That can look careless: surely an algorithm that is a thousand times faster per step matters? The Big-O race shows why the shape wins anyway. Teams of bouncing balls break through floors that get ten times stronger, and every team grows by its own class. The slow classes may start with thousands of balls, but sooner or later a faster-growing class has more, and from that floor on it is never caught again.
Constant factors and the dominant term
When an algorithm takes 5n² + 300n + 2000 steps, Big-O calls it O(n²). The 2000 matters for tiny inputs, the 300n for small ones, but as n grows the n² term takes over: at n = 1,000 it makes up more than 90% of the total, at n = 1,000,000 more than 99.99%. The factor 5 never goes away, yet it never changes how the cost grows either: double n and the time roughly quadruples, on any computer. Big-O keeps exactly that part.
Crossover points
Take a slow-growing method with a big constant, 1000 · n, and a fast-growing one with a small constant, n². For n below 1000 the quadratic method is cheaper; at n = 1000 they cost the same; beyond it the linear one wins, and by n = 1,000,000 it is a thousand times faster. Every pair of classes has such a crossover point. In the race it is the floor where one team's count of balls overtakes another's: before it the head start decides, after it the class does. Insertion sort beats merge sort on a dozen items for the same reason, and library sorts switch between them.
Polynomials against exponentials
Any exponential eventually beats any polynomial. 2ⁿ is smaller than n³ up to n = 9, but at n = 10 it is 1024 against 1000, at n = 20 about a million against 8000, at n = 40 a trillion against 64,000. Multiplying the polynomial by a big constant only moves the crossover a few steps later, because the exponential doubles with every step while n³ grows by less and less. That is why computer science calls polynomial-time problems tractable and treats exponential ones as hard: a faster computer adds a few to the largest n you can handle, it does not multiply it.
The factorial
n! = 1 · 2 · 3 · … · n grows faster still: each step multiplies by a bigger number. 10! is 3,628,800, 20! about 2.4 × 10¹⁸, and Stirling's formula n! ≈ √(2πn) (n/e)ⁿ shows that it outgrows every fixed base: it passes 10ⁿ at n = 25. Factorial time is what checking every order of n items costs, like a brute-force search for the shortest round trip through n cities. In the race on floors ×10, O(n!) is the only team whose growth ends up faster than the floors, so it is the only one that ends up speeding up.
Logarithms and slow growth
At the other end, log₂ n grows so slowly that it is nearly a constant in practice: it is 10 for a thousand, 20 for a million and 30 for a billion. That is why binary search, which needs about log₂ n comparisons, feels instant on any list. O(n log n), the cost of the best general sorting methods, is only a little worse than linear. In the race, O(log n) and O(n log n) teams pull ahead of O(1) after a few floors, but on floors that grow ten times stronger they slow down nearly as much.
Seeing billions on one screen
A race over ten floors of 10ⁿ points takes the slowest team billions of bounces and the fastest a few thousand. No ordinary time axis shows both, so the app uses a logarithmic clock: every ×10 of bounces takes the same playback time, like the decades on a log scale. On that scale a constant growth factor becomes a constant slope, so a team whose balls keep pace with the floors climbs the chart as an even staircase, a faster-growing team bends upwards and a slower one flattens out.
How the app runs the race
A team of class f has round(c · g(n)) balls on floor n, at least one, where g is the class's growth normalised to g(1) = 1 and c is its head start: H to the power 7 for O(1) down to H to the power 0 = 1 for O(n!), with H from 1 to 4. All balls of a team land together once per round, so floor n breaks after ceil(Vₙ ÷ Bₙ) rounds, and the race is worked out exactly in whole rounds before it is drawn. The clock maps τ seconds of playback to b · (10^(τ/D) − 1) rounds, with D seconds per ×10, which makes the picture, the chart and the numbers a pure function of the settings and the moment, so Step, Back and scrubbing land exactly on the same race.
Frequently asked questions
Does a faster computer help an exponential algorithm?
Only a little. A computer a thousand times faster lets an O(n) algorithm handle inputs a thousand times larger, an O(n²) one about 32 times larger, but an O(2ⁿ) one only about 10 more items, because 2¹⁰ ≈ 1000. Choosing an algorithm of a better class almost always gains more than buying speed.
Is Big-O the same as the actual running time?
No. Big-O describes how the running time grows with the input, up to a constant factor, and usually for the worst case. Two O(n log n) sorts can differ several times in real speed, and for small inputs an algorithm of a worse class can be faster. The class tells you which one wins once the input is large enough.
Why do the teams with more balls win, when fewer steps is better for an algorithm?
In the race the balls are the work done per round, so growth is a strength: think of how much a class can do, not what it costs. The lesson is the same either way. The difference between two classes grows without bound, and no constant factor can make up for it in the long run.
When does O(n!) overtake O(2ⁿ) and the polynomials?
With equal constants, n! is larger than 2ⁿ from n = 4 (24 against 16) and larger than n³ from n = 6 (720 against 216). With the app's head start of 2, where O(2ⁿ) starts with twice as many balls and O(n³) with four times as many, O(n!) passes 2 · 2ⁿ⁻¹ at n = 4 and 4n³ at n = 7.
Ready to try it?
Open PictorX in your browser — no install, no credit card required to start.
Open the Big-O Race