Skip to content

Big-O Visualized

Big-O notation answers one question: as the input gets bigger, how fast does the work grow? It ignores constants and hardware and focuses on the shape of the growth — which is what decides whether your code still works at a million items.

  • what O(1), O(log n), O(n), and O(n²) mean in practice
  • how dramatically they diverge as n grows
  • how to spot each one in real code
Big-ONameGrowsExample
O(1)constantnot at alldict/set lookup, list[i]
O(log n)logarithmicvery slowlybinary search
O(n)linearsteadilyscanning a list, x in list
O(n²)quadraticexplosivelynested loops, bubble sort

Same axes, four growth rates. At small n they look similar — but O(n²) shoots off the chart almost immediately while O(1) and O(log n) barely move:

sketch How algorithms scale with n p5.js
O(1) stays flat, O(log n) crawls, O(n) rises steadily, and O(n squared) explodes off the chart.

The lesson: an O(n²) algorithm that’s fine for 100 items can be hopeless at 100,000. When your data can grow, the Big-O is what matters — not how fast the code feels on a small test.

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading