# Asymptotic Notation & Master Theorem for Divide-and-Conquer
Exam: GATE Computer Science & Information Technology (GATE CS)
Subject: Algorithms
Canonical URL: https://gateandnet.com/exams/gate-cs/algorithms/master-theorem-and-recurrences

> Big-O, Omega, Theta bounds and solving divide-and-conquer recurrences in under 30 seconds.

## The Three Cases of Master Theorem

| Case | Condition Comparing $f(n)$ with $n^{\log_b a}$ | Resulting Time Complexity $T(n)$ |
| :--- | :--- | :--- |
| **Case 1 (Leaf Heavy)** | $f(n) = \mathcal{O}\!\left(n^{\log_b a - \epsilon}\right)$ for $\epsilon > 0$ | $\Theta\!\left(n^{\log_b a}\right)$ |
| **Case 2 (Balanced)** | $f(n) = \Theta\!\left(n^{\log_b a} \log^k n\right)$ for $k \ge 0$ | $\Theta\!\left(n^{\log_b a} \log^{k+1} n\right)$ |
| **Case 3 (Root Heavy)** | $f(n) = \Omega\!\left(n^{\log_b a + \epsilon}\right)$ and $af(n/b) \le cf(n)$ | $\Theta(f(n))$ |

> [!TRAP]
> In $T(n) = 2T(n/2) + n / \log n$, $f(n)$ is asymptotically smaller than $n$, **not polynomially smaller**! Case 1 does not apply; using extended $k = -1$ gives $\Theta(n \log \log n)$.


## Solved Practice Questions & PYQs

### [GATE CS 2023 | MCQ]
Consider the recurrence relation $T(n) = 8\,T\!\left(\frac{n}{2}\right) + n^3 \log_2 n$ for $n > 1$ and $T(1) = 1$. Which of the following is the tightest asymptotic bound for $T(n)$?
**Correct Answer:** B
**Solution:** $a = 8, b = 2 \implies n^{\log_2 8} = n^3$. Since $f(n) = n^3 \log^1 n$, Extended Master Theorem Case 2 ($k=1$) gives $T(n) = \Theta(n^3 \log^{1+1} n) = \Theta(n^3 \log^2 n)$.
