Formulate the Master Theorem for divide-and-conquer recurrences and derive the exact solution for the Merge Sort recurrence relation.
The Master Theorem provides a cookbook method for determining asymptotic bounds for divide-and-conquer recurrence relations of the general form:
T(n) = a · T(n / b) + f(n),
where a >= 1 represents the number of recursive subproblems generated at each step, b > 1 is the factor by which the input problem size is divided, and f(n) is the cost of dividing the problem and combining the subproblem solutions.
The critical watershed exponent is c_crit = log_b(a). The behavior of T(n) is determined by comparing f(n) to n^{c_crit}:
1. Case 1 (Subproblem Dominance): If f(n) = O(n^{c_crit - ε}) for some constant ε > 0, then the work is dominated by the leaves of the recursion tree, yielding T(n) = Θ(n^{log_b a}).
2. Case 2 (Balanced Work): If f(n) = Θ(n^{c_crit} · log^k n) for some k >= 0, then work is evenly distributed across all tree levels, yielding T(n) = Θ(n^{c_crit} · log^{k+1} n).
3. Case 3 (Root Dominance): If f(n) = Ω(n^{c_crit + ε}) for some ε > 0, and the regularity condition a · f(n/b) <= c · f(n) holds for some c < 1, the work is dominated by the root combine step, yielding T(n) = Θ(f(n)).
Application to Merge Sort:
In Merge Sort, the array of size n is divided into a = 2 subproblems, each of size n/b = n/2. The cost of bisecting the array and performing the linear two-way merge across n elements is f(n) = c · n = Θ(n¹).
We compute the critical exponent:
c_crit = log_b(a) = log₂(2) = 1.
Comparing f(n) with n^{c_crit}: here f(n) = Θ(n¹) = Θ(n^{c_crit} · log⁰ n), exactly matching Case 2 with k = 0.
Therefore, the asymptotic solution is:
T(n) = Θ(n^{c_crit} · log^{0+1} n) = Θ(n¹ · log₂ n) = Θ(n log₂ n).
Explicit Recurrence Tree Unrolling:
At depth 0: 1 node of size n, merge cost = n.
At depth 1: 2 nodes of size n/2, merge cost = 2 · (n/2) = n.
At depth j: 2^j nodes of size n/2^j, merge cost = 2^j · (n/2^j) = n.
The tree has height h = log₂ n. Summing across all levels from j = 0 to log₂ n − 1:
T(n) = ∑_{j=0}^{log₂ n - 1} n = n · log₂ n = Θ(n log₂ n).