What this calculates
Enter one or more input sizes (n) and see the actual operation count for five common complexity classes — O(1), O(log n), O(n), O(n log n), and O(n²) — side by side, as both a log-scale bar chart and an exact-value table. The point isn't just seeing the formulas; it's seeing how fast they pull apart from each other as n grows, which is much easier to feel with real numbers than with the notation alone.
Why the bars are log-scaled
At n = 10,000, O(log n) is around 13 and O(n²) is 100,000,000 — a linear bar chart would render every class except O(n²) as an invisible sliver. The bar width here is proportional to log₁₀(value) instead, which keeps every class visually readable at once. The exact value is always shown next to the bar and in the table below, so the log scale never hides the real number — it only affects how the comparison looks.
The formulas, exactly
- O(1) — always 1, regardless of
n. - O(log n) —
log₂(n), the standard base for algorithmic analysis (each step halves the remaining problem, as in binary search). - O(n) —
nitself. - O(n log n) —
n × log₂(n). - O(n²) —
n × n.
Every value is rounded up to the next whole number, since a fractional number of operations isn't meaningful — an actual algorithm doesn't perform 6.64 steps, it performs 7.
FAQ
I want to see these as continuous growth curves, not a table
Complexity Visualizer plots these classes — plus O(2ⁿ), which this tool doesn't cover — as continuous curves on an interactive chart that rescales as you drag the input size up.
Why does the table switch to scientific notation for large numbers?
Once a value passes a billion, a full digit string (like 100,000,000,000,000) gets hard to read at a glance — this switches to 1.00 × 10^14 above that point purely for readability. Nothing about the underlying calculation changes.
What's the maximum n I can enter?
10,000,000. Beyond that, O(n²) starts producing numbers large enough that the comparison stops being informative — the point of this tool is building intuition for how these classes diverge, not stress-testing floating point.
Where do these classes actually come from?
See Algorithm Complexity Explained for the formal definitions of Big O, Big Theta, and Big Omega, why best/worst/average case is a separate question from which notation you use, and real examples of algorithms that fall into each of these five classes.
Is anything I enter sent anywhere?
No — every calculation happens entirely in your browser. Nothing you enter here is ever sent to a server.