DevTools Hub

Search tools

Search for a developer tool

Algorithms

Complexity Visualizer

Watch O(1) through O(2ⁿ) grow apart on an interactive log-scale chart.

Part of the Algorithms Toolkit
n = 15
260
105104103102101100
n = 1n = 15
O(1)Constant1
O(log n)Logarithmic4
O(n)Linear15
O(n log n)Linearithmic59
O(n²)Quadratic225
O(2ⁿ)Exponential32,768

What this shows

Six complexity classes — O(1), O(log n), O(n), O(n log n), O(n²), and O(2ⁿ) — plotted as growth curves from n = 1 up to whatever you set the slider to. Both axes rescale every time you move it: the x-axis always spans exactly [1, n], and the y-axis (log-scaled — more on that below) always spans exactly the range those six classes actually produce at that n. That's deliberate — it's what makes dragging the slider feel like watching growth happen instead of staring at a static picture with a cursor on it.

Why the y-axis is log-scaled

At n = 60, O(2ⁿ) is over a quintillion while O(1) is still 1 — on a linear axis, five of these six curves would be indistinguishable from a flat line at the bottom. The y-axis here is log₁₀(value) instead, so every class stays visually readable across the whole range. The tradeoff is real and worth knowing: on a log scale, equal vertical distances represent equal multiplicative gaps, not equal differences — the visual distance between O(n) and O(n²) doesn't shrink just because O(2ⁿ) is on the same chart. The exact value for every class at the current n is always shown underneath the chart, so the log scale never hides the real number.

Where O(2ⁿ) permanently overtakes O(n²)

Drag the slider slowly from the low end and watch O(n²) and O(2ⁿ) specifically: at n = 3, O(n²) (9) is still ahead of O(2ⁿ) (8). They tie at n = 4 (16 each). From n = 5 onward, O(2ⁿ) is ahead for good — 32 versus 25, and the gap only widens from there. It's a small, concrete example of a general rule: any exponential function eventually overtakes any polynomial one, no matter how large the polynomial's degree — "eventually" can just take a while to arrive.

FAQ

How is this different from Big O Calculator?

Big O Calculator is for precise comparison at specific input sizes — enter exactly the n values you care about (say, 1,000 and 1,000,000) and get exact numbers for each, side by side. This tool is for seeing the shape of growth across a continuous range in one picture, including O(2ⁿ), which Big O Calculator doesn't cover. Reach for the calculator when you need a specific number; reach for this when you want the intuition for how fast these classes actually pull apart.

Why does the slider stop at 60?

O(2ⁿ) grows fast enough that the numbers stop being meaningful well before JavaScript actually runs out of numeric range — at n = 60, O(2ⁿ) is already over a quintillion operations. Going higher makes the chart more dramatic without teaching anything the lower end doesn't already show.

Where do these six formulas come from?

See Algorithm Complexity Explained for the formal definitions of Big O, Big Theta, and Big Omega, and real algorithms that land in each of these classes.

Is anything I do here sent anywhere?

No — every calculation and the chart itself render entirely in your browser. Nothing here is ever sent to a server.

Related tools