∑GateAndNet
Practice MCQs
GATE CS / Algorithms
Edit
INTERMEDIATE🔥 High-Yield Exam Topic 4 min read 4 views

Asymptotic Notation & Master Theorem for Divide-and-Conquer

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

The Three Cases of Master Theorem

CaseCondition Comparing f(n)f(n) with nlog⁡ban^{\log_b a}Resulting Time Complexity T(n)T(n)
Case 1 (Leaf Heavy)f(n)=O ⁣(nlog⁡ba−ϵ)f(n) = \mathcal{O}\!\left(n^{\log_b a - \epsilon}\right) for ϵ>0\epsilon > 0Θ ⁣(nlog⁡ba)\Theta\!\left(n^{\log_b a}\right)
Case 2 (Balanced)f(n)=Θ ⁣(nlog⁡balog⁡kn)f(n) = \Theta\!\left(n^{\log_b a} \log^k n\right) for k≥0k \ge 0Θ ⁣(nlog⁡balog⁡k+1n)\Theta\!\left(n^{\log_b a} \log^{k+1} n\right)
Case 3 (Root Heavy)f(n)=Ω ⁣(nlog⁡ba+ϵ)f(n) = \Omega\!\left(n^{\log_b a + \epsilon}\right) and af(n/b)≤cf(n)af(n/b) \le cf(n)Θ(f(n))\Theta(f(n))
🚨 Exam Trap Alert

In T(n)=2T(n/2)+n/log⁡nT(n) = 2T(n/2) + n / \log n, f(n)f(n) is asymptotically smaller than nn, not polynomially smaller! Case 1 does not apply; using extended k=−1k = -1 gives Θ(nlog⁡log⁡n)\Theta(n \log \log n).

📐 Quick Revision Formula Sheet
Standard Recurrence Form
T(n)=a T ⁣(nb)+f(n),a≥1,  b>1T(n) = a\,T\!\left(\frac{n}{b}\right) + f(n), \quad a \ge 1,\; b > 1
💡 Compare f(n) against watershed leaf cost n^{\log_b a}
Extended Case 2 (k >= 0)
f(n)=Θ ⁣(nlog⁡balog⁡kn)  ⟹  T(n)=Θ ⁣(nlog⁡balog⁡k+1n)f(n) = \Theta\!\left(n^{\log_b a} \log^k n\right) \implies T(n) = \Theta\!\left(n^{\log_b a} \log^{k+1} n\right)
💡 When k = -1, T(n) = Theta(n^{\log_b a} \log \log n)
#Algorithms#Recurrences#Master Theorem

🎯 Practice PYQs on This Topic (1)

Q1.GATE CS 2023MCQMEDIUM
+2 Marks • -0.67 Neg

Consider the recurrence relation T(n)=8 T ⁣(n2)+n3log⁡2nT(n) = 8\,T\!\left(\frac{n}{2}\right) + n^3 \log_2 n for n>1n > 1 and T(1)=1T(1) = 1. Which of the following is the tightest asymptotic bound for T(n)T(n)?

Previous TopicStacks, Queues, Linked Lists & Binary Tree PropertiesNext Topic Shortest Path & MST Algorithms: Dijkstra, Bellman-Ford, Prim & Kruskal