Tools · estimate, benchmark, visualize
Three modes: estimate ops at a given n, run real benchmarks of common patterns, and watch a recursion call tree grow with and without memoization. The point: develop the gut feel that turns "is this fast enough?" into a one-second answer.
| Complexity | Ops at this n | ~ wall clock @ 10⁹ ops/s | Verdict |
|---|
n ≤ 10: anything works, including O(n!).
n ≤ 25: O(2ⁿ) brute force, exhaustive subset search OK.
n ≤ 100: O(n³) is fine.
n ≤ 10⁴: O(n²) is the ceiling.
n ≤ 10⁶: O(n log n) is the ceiling.
n ≤ 10⁹: need O(n) or better.
Each pattern below runs in JS in your browser. Times are real wall-clock — bigger n is more dramatic. Try n = 10000 and watch the n² row spike while n log n stays flat.
| Pattern | Big-O | Ops | Time (ms) | Bar |
|---|
Quadruple n. The O(n) row should take roughly 4× as long. The O(n²) row should take roughly 16× as long. The O(n log n) row should take roughly 4.5× as long. That's Big-O made tactile.
Pick n and watch the call tree of fib(n) with and without memoization. Without memo: every subproblem recomputed → exponential. With memo: each subproblem solved once → linear. The visual difference is the entire DP lesson in one image.
Run fib(8) without memo — you'll see ~67 nodes. Then check Memoize and re-run — only ~9 unique subproblems are computed; the rest are cache hits (shown in green). The tree has the same shape, but most of it doesn't need recomputation.
The classic shapes. The vertical axis is operation count; the horizontal axis is input size. Notice how O(2ⁿ) goes vertical almost immediately while O(log n) is nearly flat.