What is the Master Theorem for solving recurrences?
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).
Previous
What is Tarjan's algorithm for finding Strongly Connected Components?
Next
What are NP, NP-Complete, and NP-Hard problems?