Cooking for 1 vs 100 guests
What Big O Measures
The analogy
A recipe for one guest tells you nothing about a wedding. Big O ignores how long one step takes and asks only: if the guest list gets ten times bigger, does the work get ten times bigger, or a hundred times bigger? It is about the shape of the growth, not the stopwatch.
Visualizer
Shape beats stopwatch
step 1 / 5Chef A — 3 steps per guest
Chef A needs 3 steps per guest. For 100 guests, 300 steps.A: 3n
def chef_a(guests): return 3 * guests # O(n) def chef_b(guests): return 10 * guests # O(n) def chef_c(guests): return guests ** 2 // 2 # O(n^2) chef_c(4) # 8 — cheapest here chef_c(300) # 45000 — and never cheapest again
Check yourself
Big O describes…