Four lines on one chart
Comparing the Curves
The analogy
Put all four growth shapes on one chart and drag the data size. At ten items they are almost indistinguishable — which is exactly why bad choices survive testing. Drag to a thousand and the quadratic curve leaves the chart entirely.
Visualizer
Four shapes of growth
step 1 / 6One curve to start: O(n). Straight line — twice the data, twice the work.O(n): the honest baseline
import math
for n in (10, 100, 1000):
print(n,
1, # O(1)
round(math.log2(n)), # O(log n)
n, # O(n)
round(n * math.log2(n)),# O(n log n)
n * n) # O(n^2)Check yourself
At n = 10, an O(n²) algorithm is…