Big-O: See at a Glance How Long Code Will Run
Drag the data-size slider and watch O(1), O(log n), O(n), and O(n²) diverge; 10× the data—who barely flinches, who blows up on the spot
THE QUESTION THIS PAGE ANSWERS
ANSWER FIRSTWhat is the key idea behind “Big-O: See at a Glance How Long Code Will Run”?
Drag the data-size slider and watch O(1), O(log n), O(n), and O(n²) diverge; 10× the data—who barely flinches, who blows up on the spot
Make the claim earn its place. Use this page as a decision aid, not a definition to memorize. Connect the idea to one real task, one observable result, and one failure that would change your mind.
Write one question you could answer with evidence after trying this idea.
A conclusion that sounds complete but leaves the key assumption untested.
Time curves for four common “playbooks”: O(1) gray (one step no matter how much data), O(log n) green (cut in half each time), O(n) blue (walk through one by one), O(n²) red (everyone compared with everyone). Drag the slider from 10 to 100,000; the right side converts to real time at “100 million ops/sec.” Watch: early on, all four lines pile together—when data is small every algorithm looks fast, which is exactly why demos lie.
A more direct question: your boss says “users will 10×”—how much slower does each playbook get? Hit “×10,” click three times and watch the gap snowball.
You've got the ruler—time to try it. Three snippets of pseudocode; pick a complexity for each. Trick: don't read every line—just ask “when data grows, how much more work does it do?”
The algorithmic cost curve in “Interactive 1 · Four curves diverge”
“Time curves for four common “playbooks”: O(1) gray (one step no matter how much data), O(log n) green (cut in half each time), O(n) blue (walk through one by one), O(n²) red (every…” is not asking you to memorize steps. It trains you to spot repeated work: as the input grows, how many comparisons, moves, or recursive calls does the program perform?
Find repeated work before declaring something fast
Break “A more direct question: your boss says “users will 10×”—how much slower does each playbook get?” into three questions: how input size changes, what each round does, and whether the next round can shrink its search space. Big-O describes growth, not an exact time on every machine; constants, memory, and data distribution still matter.
- Big-O only tracks the trend : it doesn't care how fast one run is—only how time grows as data grows
- Constants don't matter; trends kill : 2× slower is fine; growing with n² is a death sentence
- Small data hides the gap : four curves pile together in the demo stage; the explosion waits until data grows
Theoretical optimum is not always practical optimum
When AI writes an algorithm, trace a small input by hand and benchmark progressively larger inputs. That turns “You've got the ruler—time to try it.” from a slogan into a performance claim you can check.
From “Interactive 1 · Four curves diverge” to “Interactive 2 · What if data grows 10×”
“Interactive 1 · Four curves diverge” grounds the problem in “Time curves for four common “playbooks”: O(1) gray (one step no matter how much data), O(log n) green (cut in half each time), O(n) blue (walk through one by one), O(n²) red (everyone compared with everyone). D…”. “Interactive 2 · What if data grows 10×” then moves it toward “A more direct question: your boss says “users will 10×”—how much slower does each playbook get? Hit “×10,” click three times and watch the gap snowball”. Together, they show that the lesson is not just a conclusion to remember, but a claim with conditions.
Carry the judgment into the next situation
For a real task, find the repeated work first, ask how input size changes, and use a small benchmark to verify the theoretical judgment. Complexity should not become a label detached from the situation.
- “Interactive 1 · Four curves diverge”: Time curves for four common “playbooks”: O(1) gray (one step no matter how much data), O(log n) green (cut in half each time), O(n) blue (walk through one by one), O(n²) red (everyone compared with everyone). D…
- “Interactive 2 · What if data grows 10×”: A more direct question: your boss says “users will 10×”—how much slower does each playbook get? Hit “×10,” click three times and watch the gap snowball
- “The closing point”: n² causes most lag accidents : when reviewing code, hunt nested loops first
The final “The closing point” brings the discussion to “n² causes most lag accidents : when reviewing code, hunt nested loops first”. The useful thing to carry forward is knowing which judgments must be revisited when input, scale, or risk changes.
What this lesson wants to share
- Big-O only tracks the trend: it doesn't care how fast one run is—only how time grows as data grows
- Constants don't matter; trends kill: 2× slower is fine; growing with n² is a death sentence
- Small data hides the gap: four curves pile together in the demo stage; the explosion waits until data grows
- n² causes most lag accidents: when reviewing code, hunt nested loops first
I turned one judgment from this article into a small experiment I could run today. Knowing what to observe next is more useful than simply remembering the conclusion.
After reading this, I first looked for the conditions behind the idea instead of copying the method into a project. That order made the later trade-offs much clearer.
When this judgment reaches real work, which constraint should be added first? I am curious which step matters most between reading and the first practical attempt.
No discussion on this article yet.