What is the Master Theorem for solving recurrences?

Why Interviewers Ask This

Advanced questions like this reveal whether a candidate has internalized Data Structures & Algorithms deeply enough to make architectural decisions. Strong answers demonstrate both breadth and depth of experience.

Answer

The Master Theorem provides a cookbook solution for recurrences of the form T(n) = aT(n/b) + f(n), where a ≥ 1 (subproblems), b > 1 (division factor), f(n) (work at current level). Three cases based on comparing f(n) with n^(log_b(a)): Let p = log_b(a). Case 1: if f(n) = O(n^(p-ε)) for some ε > 0 (f grows slower than n^p) → T(n) = Θ(n^p). Tree work dominates. Example: T(n) = 8T(n/2) + O(n²); p = log₂8 = 3; f(n) = n² = O(n^(3-ε)) → T(n) = Θ(n³). Case 2: if f(n) = Θ(n^p × log^k(n)) → T(n) = Θ(n^p × log^(k+1)(n)). Equal work. Example: T(n) = 2T(n/2) + O(n); p = 1; f(n) = O(n¹) → T(n) = Θ(n log n) (merge sort). Case 3: if f(n) = Ω(n^(p+ε)) and regularity condition → T(n) = Θ(f(n)). Root work dominates. Example: T(n) = T(n/2) + O(n); p = 0; f(n) = O(n) = Ω(n^(0+ε)) → T(n) = Θ(n). Doesn't apply when: f(n) falls in the gap between cases or the recursion isn't of the exact form. Applications: analyze merge sort O(n log n), Strassen matrix multiplication O(n^2.807), binary search O(log n).

Common Mistake

Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong Data Structures & Algorithms candidates.