๐Ÿ“ Master Theorem: Visual Proof

Understand WHY each case works through intuitive visualizations

T(n) = aยทT(n/b) + f(n)
Compare f(n) with nlogba โ€” the "watershed" that determines which part dominates
Case 1
๐Ÿƒ Leaves Win
Case 2
โš–๏ธ Tie
Case 3
๐ŸŒณ Root Wins
When: f(n) = O(nlogba - ฮต) for some ฮต > 0
T(n) = ฮ˜(nlogba)
๐Ÿ’ก The Key Intuition

The work done at the leaves of the recursion tree dominates everything else. Each level does more work than the one above it, growing exponentially until we hit the leaves.

Work at Root
f(n)
โ‰ช
Work at Leaves
nlogba
๐Ÿ“Š Work Per Level (Growing)
Level 0
f(n)
Level 1
aยทf(n/b)
Level 2
aยฒยทf(n/bยฒ)
...
โ†— grows
Leaves
๐Ÿ† DOMINATES
๐Ÿ”ข Geometric Series
Total = 1 + r + rยฒ + ... + rh

When r > 1: Sum โ‰ˆ rh (last term dominates!)
๐ŸŽ“ Why This Works

At each level, the number of subproblems multiplies by a, while each problem shrinks by b. When a > bd (where f(n) = nd), the growth in subproblems outpaces the shrinking work per problem.

Key Insight: There are nlogba leaves, each doing O(1) work. This leaf count dominates everything else!
When: f(n) = ฮ˜(nlogba)
T(n) = ฮ˜(nlogba log n)
๐Ÿ’ก The Key Intuition

Every level of the tree does exactly the same amount of work! The work neither grows nor shrinks as we go down. Total = (work per level) ร— (number of levels).

Work at Root
cn
=
Work at Each Level
cn
๐Ÿ“Š Work Per Level (Equal!)
Level 0
cn
Level 1
cn
Level 2
cn
...
cn
Level h
cn
๐Ÿ”ข Simple Multiplication
Total = cn + cn + cn + ... + cn

= (log n + 1) ร— cn = ฮ˜(n log n)
๐ŸŽ“ Why This Works

This is the Merge Sort case! At level k, we have ak problems, each of size n/bk. The work at level k is:

ak ร— (n/bk) = n ร— (a/b)k = n ร— 1k = n

Key Insight: When a = b (like Merge Sort with a=2, b=2), every level does exactly n work. With log n levels, total is n log n.
When: f(n) = ฮฉ(nlogba + ฮต) for some ฮต > 0
T(n) = ฮ˜(f(n))
๐Ÿ’ก The Key Intuition

The work done at the root dominates everything below. Each level does less work than the one above, shrinking so fast that the total is essentially just the root's work.

Work at Root
f(n)
โ‰ซ
Work at Leaves
nlogba
๐Ÿ“Š Work Per Level (Shrinking)
Level 0
๐Ÿ† f(n) DOMINATES
Level 1
โ†˜ shrinks
Level 2
โ†˜
...
โ†˜
Leaves
tiny
๐Ÿ”ข Geometric Series (Converges!)
Total = 1 + r + rยฒ + ...

When r < 1: Sum โ†’ constant ร— first term
(The series converges, dominated by first term!)
๐ŸŽ“ Why This Works

When f(n) grows faster than nlogba, the root's work is so massive that all the recursive work combined is just a constant factor of f(n).

Key Insight: This is like a geometric series with ratio < 1. The sum 1 + 1/2 + 1/4 + ...=2, which is just 2ร— the first term. Similarly, total work โ‰ˆ constant ร— f(n).