3.1.6Complexity Analysis

Tight bounds — Θ notation; lower bounds — Ω notation

1,761 words8 min readdifficulty · medium

WHY do we need three symbols?

So the family is:

  • OO — upper bound (≤ kind of statement)
  • Ω\Omega — lower bound (≥ kind of statement)
  • Θ\Theta — tight, both at once (= kind of statement)

WHAT exactly do they mean? (Derivation from first principles)

We compare functions f(n)f(n) (your cost) and g(n)g(n) (a clean reference like nn, n2n^2, nlognn\log n) as nn\to\infty. We don't care about small nn or constant factors — only the shape of growth.

Building OO first

We want "ff grows no faster than gg." Growth "no faster" means that after some point, ff stays under a scaled copy of gg:

f(n)=O(g(n))    c>0, n0>0 : 0f(n)cg(n)nn0f(n) = O(g(n)) \iff \exists\, c>0,\ n_0>0 \ :\ 0 \le f(n) \le c\,g(n)\quad \forall n\ge n_0

Mirror it to get Ω\Omega

"ff grows no slower than gg" — flip the inequality:

Sandwich them to get Θ\Theta

If gg is both a ceiling and a floor (with possibly different constants), the growth is pinned:

Figure — Tight bounds — Θ notation; lower bounds — Ω notation

Worked examples


Steel-manned mistakes


Recall Feynman: explain to a 12-year-old

Imagine guessing how tall a kid will be. Big-OO is the parent saying "he won't be taller than 6 feet" (a ceiling). Big-Ω\Omega is "he won't be shorter than 5 feet" (a floor). Big-Θ\Theta is when both squeeze together — "he'll be right around 5'6", give or take" — so you know his height pretty exactly. We ignore baby photos (small nn) and don't care if you measure in inches or cm (constants); we only care how tall he ends up.


Flashcards

Definition of f=Ω(g)f=\Omega(g)?
c>0,n0>0: 0cg(n)f(n)\exists c>0,n_0>0:\ 0\le c\,g(n)\le f(n) for all nn0n\ge n_0 (eventual floor).
Definition of f=Θ(g)f=\Theta(g)?
c1,c2,n0>0: 0c1g(n)f(n)c2g(n)\exists c_1,c_2,n_0>0:\ 0\le c_1g(n)\le f(n)\le c_2g(n) for all nn0n\ge n_0.
Θ\Theta in terms of OO and Ω\Omega?
f=Θ(g)    f=O(g) and f=Ω(g)f=\Theta(g) \iff f=O(g)\ \text{and}\ f=\Omega(g).
Limit test: if limf/g=0\lim f/g = 0?
f=O(g)f=O(g) but not Ω(g)\Omega(g) → strictly smaller order (o(g)o(g)).
Limit test: if limf/g=\lim f/g = \infty?
f=Ω(g)f=\Omega(g) but not O(g)O(g) → strictly larger order (ω(g)\omega(g)).
Limit test: if 0<limf/g<0<\lim f/g<\infty?
f=Θ(g)f=\Theta(g) — same growth shape.
Is n2=O(n)n^2=O(n)?
No; ncn\le c can't hold for all large nn. But n2=Ω(n)n^2=\Omega(n).
Why does Ω\Omega ≠ "best case"?
Bound symbols measure a function's growth; best/worst/average is a separate axis (which input).
Lower bound for comparison sorting, and why?
Ω(nlogn)\Omega(n\log n), from decision-tree height log2(n!)=Θ(nlogn)\log_2(n!)=\Theta(n\log n).
Which Big-notation relation is symmetric?
Θ\Theta: f=Θ(g)    g=Θ(f)f=\Theta(g)\iff g=\Theta(f).
Insertion sort: single Θ\Theta for runtime?
No — best Θ(n)\Theta(n), worst Θ(n2)\Theta(n^2), so overall only O(n2)O(n^2), Ω(n)\Omega(n).
Roles of cc and n0n_0?
cc ignores constant factors; n0n_0 ignores small-nn behavior.

Connections

Concept Map

as n to infinity

ceiling ≤

floor ≥

mirror inequality

AND combine

AND combine

uses

uses

kills constants and small-n noise

L=0 gives

L=infinity gives

0 < L < infinity gives

example

f n cost vs g n reference

Compare growth shapes

Big-O upper bound

Omega lower bound

Theta tight bound

constant c and threshold n0

Limit L of f over g

3n^2+5n+7 = Theta n^2

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, complexity me teen bhai hote hain: Big-O, Big-Omega aur Big-Theta. Big-O bolta hai "isse zyada slow nahi hoga" — yani upar ki ceiling. Big-Omega (Ω\Omega) ulta hai: "isse zyada fast nahi hoga" — yani niche ka floor. Aur jab dono ek hi shape (jaise n2n^2) ke nikal aaye, tab Theta (Θ\Theta) milta hai — matlab growth bilkul pin ho gayi, na upar na niche. Isiliye Theta ko tight bound kehte hain.

Formula ka asli jadoo do cheezon me hai: constant cc aur threshold n0n_0. cc constant factors ko ignore karta hai (2x slow machine se class nahi badalti), aur n0n_0 chhote nn ke jhamele ignore karta hai (sirf bade nn ka trend dekho). Ek fast trick: ratio f/gf/g ka limit lo — agar 00 aaya to ff chhota order, agar infinity aaya to bada order, aur agar koi finite non-zero number aaya, to Θ\Theta confirmed, kyunki constant ratio ka matlab same shape.

Sabse bada confusion: log sochte hain "Ω\Omega matlab best case." Galat! Best/worst/average alag axis hai (kaun sa input chuna). O,Ω,ΘO,\Omega,\Theta to sirf function ki growth naapte hain. Tum keh sakte ho "worst case time Ω(nlogn)\Omega(n\log n) hai" — yani worst case ka bhi floor.

Yeh matter kyun karta hai? Kyunki Ω\Omega se hum problem ki limit jaante hain. Jaise comparison sorting kabhi nlognn\log n se fast nahi ho sakti (Ω(nlogn)\Omega(n\log n)). Merge sort O(nlogn)O(n\log n) deta hai — dono mil gaye, to merge sort optimal hai. Isi tarah Ω\Omega batata hai ki "ab isse aage smart hone ka fayda nahi."

Go deeper — visual, from zero

Test yourself — Complexity Analysis

Connections