Big-O chart
See why some programs finish instantly while others “hang”: a growth chart of step counts and a table for n = 10, 100 and 1000.
Growth chart
The Y axis is cut at 400 steps so the fast functions stay visible: O(n!) and O(2ⁿ) leave the chart already at a small n.
How many steps
| Complexity | n = 10 | n = 100 | n = 1000 | Example |
|---|---|---|---|---|
| O(1)Constant | 1 | 1 | 1 | Reading an array item by index |
| O(log n)Logarithmic | 3.3 | 6.6 | 10.0 | Binary search in a sorted list |
| O(n)Linear | 10 | 100 | 1000 | One pass over a list |
| O(n log n)Linearithmic | 33.2 | 664.4 | 9965.8 | Merge sort, quicksort |
| O(n²)Quadratic | 100 | 10 000 | 1M | Two nested loops |
| O(2ⁿ)Exponential | 1024 | ≈10^30 | ≈10^301 | Trying every subset |
| O(n!)Factorial | 3.6M | ≈10^157 | ∞ | Trying every permutation |
If a step takes a billionth of a second, O(n²) for n = 1000 is a hundredth of a second, while O(2ⁿ) for n = 100 takes longer than the universe has existed.
More in the Study
Write fast code
The courses teach not only syntax but how to choose the right approach.