Skip to content
ΣDSA Patterns
Menu
Language

Foundations

Growth rates & Big-O curves

Plot O(1)…O(n!) on one chart; watch how each bound scales as n grows.

Question: is O(n²) OK for n ≤ 10⁴?

It depends on the cap. 10⁴ × 10⁴ = 10⁸ operations blow a 1-second judge budget on its own. If n ≤ 10⁵ then O(n²) = 10¹⁰ and you time out. This page exists to make "is this bound fast enough?" a 5-second visual and numerical call.

By the numbers

nlog₂ nnn log nn²2ⁿ
10³1010³10⁴10⁶~10³⁰⁰
10⁶2010⁶2·10⁷10¹²blows up
10⁹3010⁹3·10¹⁰10¹⁸blows up

One line: log n stays tiny even for huge n, n log n is survivable at 10⁶, n² dies past 10⁵, 2ⁿ is physically impossible past n ≈ 30.

Where each one comes from

Every loop shape maps to a growth class:

Trap: "merge sort has nested loops, so it's O(n²)"

Wrong. The inner loop in merge sort is for a single level, and each level touches the entire array once (n work). What looks nested is actually n work at each of log n levels: n · log n, not n · n. Same fallacy: "there are two loops, so O(n²)". Sequential loops add (n + n = 2n → O(n)), they don't multiply.

Where to go next

Exercise

Pause the chart and set n = 20. Predict the O(n²) andO(n log n) values, then hover them. Now bump to n = 40: how many times did the gap grow?

O(1)1.0O(log n)4.6O(n)—O(n log n)—O(n²)—O(2ⁿ)—O(n!)—
n = 25
operations01020250102025n (input size)
Speed

← All math topics →