On this page
When a textbook says an algorithm runs in O(n log n), it is making a precise promise about large inputs, not a rough guess. Here are the definitions, the numbers, the common mistakes and a limit test.
What does big O notation actually mean?
The US National Institute of Standards and Technology keeps a Dictionary of Algorithms and Data Structures with the definitions used in computing:
Big O (upper bound): f(n) = O(g(n)) means there are positive constants c and k such that 0 ≤ f(n) ≤ c·g(n) for all n ≥ k.
Big Ω (lower bound): f(n) = Ω(g(n)) means there are positive constants c and k such that 0 ≤ c·g(n) ≤ f(n) for all n ≥ k (NIST entry for Ω).
Big Θ (tight bound): f(n) = Θ(g(n)) means there are positive constants c₁, c₂ and k such that 0 ≤ c₁·g(n) ≤ f(n) ≤ c₂·g(n) for all n ≥ k (NIST entry for Θ).
In every case NIST adds that c and k must be fixed for the function and must not depend on n. That one rule is where most wrong proofs break.
Paul Bachmann proposed the notation in 1894 and Edmund Landau extended it in 1909 (Wikipedia: big O notation); Donald Knuth defined Ω and Θ in the form computer scientists now use in Big Omicron and big Omega and big Theta (SIGACT News, 1976).
How do you prove 3n² + 5n + 2 = Θ(n²)?
Upper bound: for n ≥ 1, 5n ≤ 5n² and 2 ≤ 2n², so 3n² + 5n + 2 ≤ 10n². Take c₂ = 10 and k = 1.
Lower bound: for n ≥ 1, 3n² + 5n + 2 ≥ 3n². Take c₁ = 3.
Both hold from n = 1 on, so the function is Θ(n²). It is also O(n³), which is true but tells you less.
How fast do log n, n, n log n, n², 2ⁿ and n! grow?
We worked these out for n = 10, 100 and 1000 (logs to base 2, large values rounded):
log₂ n: 3.3, 6.6, 10.0
n: 10, 100, 1,000
n log₂ n: 33, 664, 9,966
n²: 100, 10,000, 1,000,000
2ⁿ: 1,024, about 1.27 × 10³⁰, about 1.07 × 10³⁰¹
n!: 3,628,800, about 9.33 × 10¹⁵⁷, about 4.02 × 10²⁵⁶⁷
Going from n = 10 to n = 100 multiplies n² by 100, but multiplies 2ⁿ by more than 10²⁷. Each function eventually overtakes the one above it, whatever constant sits in front. To estimate n! without multiplying a thousand numbers, see Stirling's approximation for n!.
What are the common mistakes with big O?
Treating O as equals. The NIST big O entry warns that the notation is often misused to mean equal to rather than less than, and that equal to is what Θ expresses. Saying binary search is O(n) is true; it is just a loose bound.
Reading the = sign as an equation. n = O(n²) and n² = O(n²) do not give n = n²; the expression is an inequality.
Letting the constant depend on n. Writing n² ≤ c·n with c = n proves nothing, because c must be fixed.
Dropping bases in the wrong place. log₂ n and log₁₀ n differ only by a constant factor, so O(log n) needs no base. But 2ⁿ and 4ⁿ are different classes, because 4ⁿ/2ⁿ = 2ⁿ grows without bound.
How do you compare growth rates using limits?
Work out L = lim f(n)/g(n) as n → ∞.
If L = 0, f grows strictly slower: f = O(g) but not Ω(g).
If L is a positive finite number, f = Θ(g).
If L = ∞, f grows strictly faster: f = Ω(g) but not O(g).
Why it works: if the ratio tends to a finite L, then beyond some n it stays below L + 1, so c = L + 1 and that n as k satisfy the definition. The test gives no answer when the limit does not exist. For f(n) = n(2 + sin n) against n, the ratio 2 + sin n keeps swinging, yet n ≤ f(n) ≤ 3n shows f = Θ(n) straight from the definition.
Two quick comparisons:
n log n against n²: the ratio is (log n)/n, which tends to 0 by L'Hôpital's rule, so n log n = O(n²) and not the reverse.
n! against 2ⁿ: n!/2ⁿ = (1/2)(2/2)(3/2)…(n/2). For n ≥ 3 every factor after the first is at least 1, so the product is at least n/4, which grows without bound. So n! = Ω(2ⁿ) and not O(2ⁿ).
The same habit of keeping only the leading behaviour runs through asymptotic expansions.
A five-step checklist for exam answers
Write the definition with c and k named.
Find c and k explicitly, and check that neither involves n.
For Θ, prove both bounds, not just one.
To compare two functions, try the limit of f/g first.
If that limit does not exist, return to the definition.
To practise these proofs, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer. If the limits or logarithms underneath feel shaky, the Fermi Concept Library gives every concept in mathematics and computing its own lesson.



