Data Structures and Big-O Without the Maths Degree Big-O: Counting Steps, Not Seconds
1 / 5
Next
Big-O: Counting Steps, Not Seconds ~15min

The question it answers

Not "how fast is this?" but "what happens when the data gets ten times bigger?"

The four you meet daily

  • O(1) constant. Same work regardless of size. Reading arr[5] or a Map lookup
  • O(n) linear, one pass. A single loop, filter, includes
  • O(n log n), good sorting. Array.sort
  • O(n²) quadratic, a loop inside a loop. The one that kills you

Why n² matters so much

n = 10010,000 stepsinstant
n = 1,0001,000,000noticeable
n = 10,000100,000,000the page freezes

It works perfectly with your test data and dies in production. That is the whole story of most performance incidents.

Constants are dropped

O(2n) is written O(n). Big-O describes the SHAPE of growth, not the exact cost. A well-written O(n²) can beat an O(n) one at small sizes, which is why you measure as well as reason.

Tasks
Preview