ABSTRACT

The Master Theorem provides a “cookbook” solution for the asymptotic analysis of divide-and-conquer recurrences. It allows us to determine the Big-O complexity by simply comparing the rate of subproblem proliferation to the rate of work done at each level.


The Formal Template

If , where , and:

  • : The number of subproblems (how many branches the tree has).
  • : The factor by which the subproblem size is reduced.
  • : The exponent of the work done outside the recursive calls (the “cost of combining”).

The Three Cases (The Intuition)

The solution depends on the relationship between and .

Case 1: (The “Top-Heavy” Case)

  • Complexity:
  • Meaning: The cost of the work at the root (the “combine” step) is so high that it dominates the total runtime. The recursive calls are relatively “cheap.”
  • Example: .

Case 2: (The “Balanced” Case)

  • Complexity:
  • Meaning: The work is distributed evenly across all levels of the recursion tree. Each level does the same amount of work, so we multiply the work per level by the number of levels ().
  • Example: (Merge Sort).

Case 3: (The “Bottom-Heavy” Case)

  • Complexity:
  • Meaning: The number of subproblems grows so quickly that the work at the “leaves” of the recursion tree dominates the total runtime.
  • Example: .

Step-by-Step Application

To solve any Master Theorem problem:

  1. Identify and from the recurrence.
  2. Calculate .
  3. Compare vs :
    • If Answer is .
    • If Answer is .
    • If Answer is .

Important Limitations

The Master Theorem cannot be used if:

  • is not a constant (e.g., ).
  • is not a polynomial (e.g., or ).
  • is not a constant (e.g., ).
  • The Gap Case: In advanced cases, if is “just barely” smaller or larger than (e.g., by a factor smaller than a polynomial), the basic Master Theorem fails.