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 you’ll learn

  • what O(1), O(log n), O(n), and O(n²) mean in practice
  • how dramatically they diverge as nn grows
  • how to spot each one in real code

The common complexities

Big-ONameGrowsExample
O(1)constantnot at alldict/set lookup, list[i]list[i]
O(log n)logarithmicvery slowlybinary search
O(n)linearsteadilyscanning a list, x in listx in list
O(n²)quadraticexplosivelynested loops, bubble sort

Watch them diverge

Same axes, four growth rates. At small nn they look similar — but O(n²)O(n²) shoots off the chart almost immediately while O(1)O(1) and O(log n)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²)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.

Try it: Big-O Exercises

Exercise 1 – Constant time O(1)

Exercise 2 – Linear time O(n)

Exercise 3 – Quadratic time O(n²)

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did