Skip to content

Latest commit

 

History

History
59 lines (51 loc) · 2.72 KB

File metadata and controls

59 lines (51 loc) · 2.72 KB

Lecture 11: Master Theorem Derivation & Insights [16/02/2026]

Course: Advanced Data Structures and Algorithms


1. Simplified Master Theorem [00:01:02]

  • General Form: $T(n) = a T(n/b) + n^c$
  • Parameters:
    • $a$: Number of subproblems (copies).
    • $n/b$: Size of each subproblem.
    • $n^c$: Combining/Splitting cost (work done at the current level).
  • Goal: Find a closed-form solution to avoid manual expansion.

2. Derivation via Expand and Simplify [00:07:49]

  • Substitution: Assume $n = b^k$.
  • Chain of Expansion:
    • $T(b^k) = a T(b^{k-1}) + (b^k)^c$
    • $T(b^k) = a^2 T(b^{k-2}) + a(b^{k-1})^c + (b^k)^c$
    • $T(b^k) = a^k T(1) + \sum_{i=0}^{k-1} a^i (b^{k-i})^c$
  • Resulting Geometric Progression:
    • The sum involves a ratio $x = b^c / a$.
    • The behavior depends on whether $x$ is $< 1$, $= 1$, or $> 1$.

3. The Three Cases of Master Theorem [00:28:01]

  • Case 1: $b^c < a$ (Subproblem work dominates)
    • $T(n) = \Theta(n^{\log_b a})$
    • Example: Karatsuba ($3 > 2^1$) yields $n^{\log_2 3} \approx n^{1.59}$.
  • Case 2: $b^c = a$ (Work is equal across levels)
    • $T(n) = \Theta(n^c \log n)$
    • Example: Merge Sort ($2 = 2^1$) yields $n \log n$.
  • Case 3: $b^c > a$ (Root combining cost dominates)
    • $T(n) = \Theta(n^c)$
    • Example: A hypothetical algorithm where the merge cost is so high ($n^2$) that splitting doesn't save asymptotic time.

4. Recursion Tree Visualization [00:58:16]

  • Nodes: Circular nodes represent recursive calls ($T$); square nodes represent concrete work done ($n^c$).
  • Levels: Level $i$ has $a^i$ nodes, each doing $(n/b^i)^c$ work.
  • Total Work: The sum of work at each horizontal level.

5. Non-Standard Recurrences [01:18:37]

  • Case Study: $T(n) = 2T(n/2) + n \log n$.
    • Since $n \log n \neq n^c$, Master Theorem doesn't apply directly.
    • Manual Expansion: $T(n) = n T(1) + n \sum \log(n/2^i)$.
    • Result: $\Theta(n \log^2 n)$.
  • Mathematical Sensitivity: Small changes in subproblems (reducing $a$ from 4 to 3) or combining costs (reducing $c$) result in massive asymptotic performance gains ($n^2 \to n^{1.59}$).

6. Philosophy: Mathematics as a Creative Handle [00:53:30]

  • If an algorithm is slow, the Master Theorem identifies the exact bottleneck.
  • Cluelessly tinkering with code is less effective than mathematically analyzing if one should focus on reducing the number of subproblems ($a$) or the merging efficiency ($c$).
  • "Math works at a meta-level... it gives you a generalized view."

Key Terms Corrected:

  • cross voiced -> Karatsuba's
  • a copies -> $a$ copies
  • B k -> $b^k$
  • D -> $d$ (base case constant)
  • alpha -> $\alpha$ (constant factor)
  • k times k plus 1 by 2 -> $k(k+1)/2$