Main

Asymptotic Notation

Big-O, Θ, Ω — what the symbols promise and what they don't.

Last updated 27 June 2026

Definitions

For functions f,g:NR0f, g : \N \to \R_{\ge 0}:

Definition (Big-O).

fO(g)f \in O(g) iff there exist c>0c > 0 and n0n_0 such that f(n)cg(n)f(n) \le c\,g(n) for all nn0n \ge n_0.

Ω\Omega is the mirror lower bound, and fΘ(g)f \in \Theta(g) means both. Note what is not promised: nothing about small nn, nothing about constants — an O(nlogn)O(n \log n) algorithm can lose to an O(n2)O(n^2) one on every input you will ever run.[1]

Reading code

def has_duplicate(xs):
    seen = set()
    for x in xs:          # n iterations
        if x in seen:     # O(1) expected
            return True
        seen.add(x)
    return False          # total: O(n) expected, O(n) space

Compare with the O(nlogn)O(n \log n) sort-first approach or the O(n2)O(n^2) nested loop — three points on the time/space trade-off curve for the same problem.

A decision habit

yes

no

show Ω(·)

no

Need a bound?

Worst case
matters?

Prove O(·) upper bound

Average / amortised
analysis

Is it tight?

Θ(·) — done

The flowchart is the discipline: an upper bound alone is a claim about your proof, not about the algorithm. Tightness is a separate theorem. This connects directly to the machine model — asymptotics are only meaningful relative to a cost model.


  1. The extreme case: galactic algorithms, asymptotically optimal but useless below astronomical input sizes. ↩︎

complexityanalysis

← Back to Algorithms