operations for n = 8 — click any row
O(1)array access arr[i]1best
O(log n)binary search3excellent
O(n)linear search8good
O(n log n)merge sort24ok
O(n²)bubble sort64slow
O(2ⁿ)naive fibonacci256avoid
Big O describes how runtime grows as input size n increases.
We drop constants and lower-order terms — only the dominant growth shape matters.
start
1 / 14
SPD0.5×
click to pause · hover for controls · fullscreen for more

Time Complexity

How algorithms scale

Visual by thisgirltech

BeginnerConcept

Seven complexity classes are plotted together: O(1), O(log n), O(n), O(n log n), O(n²), O(2ⁿ), and O(n!). The animation auto-sweeps input size n from 1 to 32 for each class in turn, so you can watch the operations counter climb and the dot move up the curve.

Use the tabs to jump to any class, or drag the n slider to explore manually. The bar chart, comparison table, and ops counter all update live.

The key thing to notice: all curves start close together near n=0. By n=32, O(n²) is already at 1,024 operations while O(1) is still at 1. For O(2ⁿ) and O(n!), the counter hits billions before n even reaches 30.

O(1) and O(log n) — always safe

Constant and logarithmic growth are practically flat at any realistic input size. O(log n) at n=1,000,000 is only 20 operations.

O(n) and O(n log n) — the sweet spot

Linear and linearithmic algorithms scale predictably. O(n log n) is the theoretical lower bound for comparison-based sorting — you cannot sort faster in general.

O(n²) — watch the curve break away

At n=100 you have 10,000 ops. At n=1,000 you have 1 million. Quadratic algorithms appear naturally from nested loops — always ask if the inner loop can become a hash lookup.

O(2ⁿ) and O(n!) — only for tiny inputs

n=30 in O(2ⁿ) exceeds 1 billion operations. n=13 in O(n!) already exceeds 6 billion. These only appear in brute-force exhaustive search.

TIP

Drag the n slider slowly from 1 to 32 while on O(n²), then switch to O(2ⁿ) — notice how O(n²) climbs steadily while O(2ⁿ) suddenly explodes off the chart. That visual separation is the entire point of Big O.

COLOUR LEGEND

O(1) — Constant
O(log n) — Logarithmic
O(n) — Linear
O(n log n) — Linearithmic
O(n²) — Quadratic
O(2ⁿ) — Exponential
O(n!) — Factorial