Skip to content
Part IA Lent Term

Asymptotic Notation: Big-O, Big-Ω, and Big-Θ

Big-O: Asymptotic Upper Bound

f(n)=O(g(n))f(n) = O(g(n)) if there exist positive constants cc and n0n_0 such that for all n≥n0n \ge n_0:

0≤f(n)≤c⋅g(n)0 \le f(n) \le c \cdot g(n)

In words: ff grows at most as fast as gg, ignoring constant factors and small inputs. OO is pronounced “big-O”.

Big-Ω\Omega: Asymptotic Lower Bound

f(n)=Ω(g(n))f(n) = \Omega(g(n)) if there exist positive constants cc and n0n_0 such that for all n≥n0n \ge n_0:

0≤c⋅g(n)≤f(n)0 \le c \cdot g(n) \le f(n)

In words: ff grows at least as fast as gg. The purple circles (worst-case cost) must be above the curve c⋅g(n)c \cdot g(n).

Big-Θ\Theta: Asymptotically Tight Bound

f(n)=Θ(g(n))f(n) = \Theta(g(n)) iff f(n)=O(g(n))f(n) = O(g(n)) and f(n)=Ω(g(n))f(n) = \Omega(g(n)). In words: ff and gg grow at the same rate, within constant factors.

Formal Definition

There exist c1,c2>0c_1, c_2 > 0 and n0n_0 such that for all n≥n0n \ge n_0:

0≤c1⋅g(n)≤f(n)≤c2⋅g(n)0 \le c_1 \cdot g(n) \le f(n) \le c_2 \cdot g(n)

Examples

FunctionBig-OBig-Ω\OmegaBig-Θ\Theta
3n2+2n+13n^2 + 2n + 1O(n2)O(n^2) ✓, O(n3)O(n^3) ✓Ω(n2)\Omega(n^2) ✓, Ω(n)\Omega(n) ✓Θ(n2)\Theta(n^2) ✓
nlog⁡nn \log nO(n2)O(n^2) ✓, O(nlog⁡n)O(n \log n) ✓Ω(n)\Omega(n) ✓Θ(nlog⁡n)\Theta(n \log n) ✓
n2n^2O(n2log⁡n)O(n^2 \log n) ✓Ω(n2)\Omega(n^2) ✓Cannot say n2=O(nlog⁡n)n^2 = O(n \log n) ✗

Proving 3n2+2n+1=O(n2)3n^2 + 2n + 1 = O(n^2)

We need cc and n0n_0 such that 3n2+2n+1≤c⋅n23n^2 + 2n + 1 \le c \cdot n^2 for all n≥n0n \ge n_0.

For n≥1n \ge 1: 2n≤2n22n \le 2n^2 and 1≤n21 \le n^2, so 3n2+2n+1≤3n2+2n2+n2=6n23n^2 + 2n + 1 \le 3n^2 + 2n^2 + n^2 = 6n^2.

Choose c=6c = 6, n0=1n_0 = 1. ✓

Common Growth Rates

Ranked from slowest to fastest:

O(1)<O(log⁡n)<O(n)<O(n)<O(nlog⁡n)<O(n2)<O(n3)<O(2n)<O(n!)O(1) < O(\log n) < O(\sqrt{n}) < O(n) < O(n \log n) < O(n^2) < O(n^3) < O(2^n) < O(n!)

The base of the logarithm is irrelevant: log⁡2n\log_2 n and log⁡10n\log_{10} n differ by a constant factor (log⁡2n=log⁡210⋅log⁡10n\log_2 n = \log_2 10 \cdot \log_{10} n), which big-O absorbs.

Practical Interpretation

  • O(1)O(1): constant time, e.g. array access, arithmetic
  • O(log⁡n)O(\log n): binary search depth, divide-and-conquer recursion depth
  • O(n)O(n): single pass over all elements
  • O(nlog⁡n)O(n \log n): efficient comparison-based sorting
  • O(n2)O(n^2): nested loops, insertion sort worst case
  • O(2n)O(2^n): enumerating all subsets

Θ\Theta, OO, and Ω\Omega are Sets

Formally, O(g(n))O(g(n)) is a set of functions. Writing f(n)=O(g(n))f(n) = O(g(n)) means f(n)∈O(g(n))f(n) \in O(g(n)). This set perspective makes the notation transitive: if f∈O(g)f \in O(g) and g∈O(h)g \in O(h), then f∈O(h)f \in O(h). Likewise for Θ\Theta and Ω\Omega. In addition, f∈Θ(g)f \in \Theta(g) iff g∈Θ(f)g \in \Theta(f) (symmetry).

Summary

NotationMeaningMnemonic
O(g(n))O(g(n))Upper bound”at most”
Ω(g(n))\Omega(g(n))Lower bound”at least”
Θ(g(n))\Theta(g(n))Tight bound”exactly” (within constants)
Rule of thumbDrop constants and lower-order terms3n2+4n→O(n2)3n^2 + 4n \to O(n^2)