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
nngrows - how to spot each one in real code
The common complexities
| Big-O | Name | Grows | Example |
|---|---|---|---|
| O(1) | constant | not at all | dict/set lookup, list[i]list[i] |
| O(log n) | logarithmic | very slowly | binary search |
| O(n) | linear | steadily | scanning a list, x in listx in list |
| O(n²) | quadratic | explosively | nested 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:
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 coffeeWas this page helpful?
Let us know how we did
