CS concepts
Big-O Notation in Plain English
O(1), O(n), O(n²) — what they actually mean, why they matter, and why nobody cares how fast your code runs on ten items.
september 2026·3 min read
Big-O notation is the thing students nod along to in class and then quietly Google at midnight. Let's fix that in five minutes, no math degree needed.
What it's actually measuring
Big-O doesn't measure speed. It measures *how fast things get worse* as your data grows.
That's a strange sentence, so here's what it means: nobody cares whether your code handles 10 items in 0.001 or 0.002 seconds. What matters is what happens at 10 million items. Does it take twice as long? A thousand times as long? Until the end of time? Big-O is the answer to that question.
O(1) — grabbing the top book off a stack
O(1) is "constant time." No matter how big the pile gets, the work stays the same.
Example: grabbing the top book off a stack. Whether the stack has 10 books or 10,000, it's one grab. Looking up a word you already have the page number for. Checking the first item in a list.
O(n) — flipping through every page
O(n) is "linear time." Double the data, double the work.
Example: flipping through every page of a book to find one word. Ten pages takes ten flips; a thousand pages takes a thousand. Searching an unsorted list works the same way — in the worst case, you check every item.
Most everyday code is O(n), and that's completely fine.
O(n²) — comparing every student with every other student
O(n²) is "quadratic time." Double the data, *four times* the work. This is where things start to hurt.
Example: comparing every student in a class with every other student to find who has the same birthday. With 30 students, that's about 900 comparisons. With 300 students, it's 90,000. The class grew 10×, the work grew 100×.
This is the one I warn my students about. Nested loops — a loop inside a loop — are the usual suspect. They feel harmless on small test data and then melt down in production.
O(log n) — the phone book trick
O(log n) deserves an honorable mention because it's the clever one.
Looking up a name in a phone book: you open roughly in the middle, check if your name comes before or after, and throw away half the book. Repeat. Every step halves the problem. A million names takes about 20 steps. A billion takes about 30.
That's why binary search feels like magic the first time you see it.
Why programmers obsess over this
Here's the practical version I give my students:
- O(1) and O(log n): you're fine. Stop optimizing.
- O(n): usually fine. This is normal code.
- O(n²): fine for hundreds of items, painful for millions. Think before you nest loops.
- Anything worse (O(2ⁿ)): only for tiny inputs. This is where problems become literally unsolvable at scale.
Big-O is not about being clever. It's about not being surprised. The programmer who knows their search is O(n²) won't be shocked when it falls over on real data.
The one-sentence version
Big-O tells you how your code's workload grows as your data grows — so you can spot the algorithms that will betray you at scale before they do.
Aaquib Ali is a computer science and mathematics teacher. He writes about CS and AI in plain language.
← All articles