Level 1:a nodes, each work f(n/b) → total af(n/b).
Level i:ai nodes, each size n/bi, work aif(n/bi).
Last level: size shrinks to 1 when n/bL=1⇒L=logbn.
Now count the leaves. The number of leaves is
alogbn=nlogba=nccrit.Why? Use alogbn=(blogba)logbn=blogba⋅logbn=(blogbn)logba=nlogba. So leaf cost =Θ(nlogba).
The sum is essentially a geometric series comparing f(n) to nlogba:
If f is smaller (f=O(nlogba−ϵ)): the series grows downward, leaves
dominate → T(n)=Θ(nlogba).
If f is equal (f=Θ(nlogba)): every level costs about the same, and there
are logbn levels → multiply by logn.
If f is bigger (f=Ω(nlogba+ϵ)): the root dominates → T(n)=Θ(f(n))
(needs a regularity check so the series actually converges to the root).
Polynomially biggerf + regularity → Case 3 → answer f(n).
Only a log gap between cases → not basic Master; use extended Case 2.
Recall Feynman: explain to a 12-year-old (click to reveal)
Imagine a chore that you split among friends. Each round you hand each friend a smaller chore,
but you also do some sorting work yourself. Two costs fight: the giant pile of tiny chores at
the bottom vs the big sorting you do at the top. The Master Theorem is just a referee:
count how fast chores multiply (a) versus how fast they shrink (b). If tiny chores swamp
you, the answer is the leaf cost. If your own sorting swamps you, the answer is the top cost.
If they're a tie, you pay the same on every floor of the building, so you multiply by the number
of floors (logn).
Dekho, Master Theorem ka funda simple hai: jab bhi koi divide-and-conquer algorithm likhte ho,
woh problem ko chhote tukdo mein todta hai. Recurrence aati hai T(n)=aT(n/b)+f(n) — yahan a
matlab kitne subproblems banaye, b matlab har baar input kitna chhota hua (n/b), aur f(n)
matlab divide aur combine ka jo extra kaam karna pada wahi level pe.
Ab pura khel ek race hai. Ek taraf hai leaves ka total cost jo nikalta hai nlogba,
aur doosri taraf hai tumhara f(n). Dono ko compare karo. Agar f(n) chhota hai (polynomially),
toh leaves jeet gaye → answer Θ(nlogba) (Case 1). Agar dono barabar hain, toh har
level pe same kaam, aur logbn levels — isliye ek extra logn multiply hota hai → Case 2.
Agar f(n) bada hai aur regularity condition pass karta hai, toh root jeet gaya → answer
Θ(f(n)) (Case 3).
Yaad rakhne ka tarika: "LET" — Leaves, Equal, Top. Merge sort dekho: 2T(n/2)+n, yahan
log22=1, aur f=n=n1, dono barabar → Case 2 → nlogn. Bas itna dhyaan rakho ki "bada"
ya "chhota" ka matlab hai polynomially (yaani nϵ ka farak), sirf log ka farak
nahi. Agar sirf log ka gap hai (jaise nlogn vs n), toh basic theorem fail ho jaata hai —
extended Case 2 use karna padta hai. Yeh chhoti si galti exams mein bahut log karte hain!