Master Theorem Solver

Solve recurrence relations of the form T(n) = aT(n/b) + f(n)

Input Parameters

About the Master Theorem

The Master Theorem provides a solution to recurrence relations of the form:

T(n) = aT(n/b) + f(n)

The Three Cases:

Case 1:

If f(n) = O(n^(log_b(a) - ε)) for some ε > 0, then T(n) = Θ(n^(log_b(a)))

Case 2:

If f(n) = Θ(n^(log_b(a)) * log^k(n)) for some k ≥ 0, then T(n) = Θ(n^(log_b(a)) * log^(k+1)(n))

Case 3:

If f(n) = Ω(n^(log_b(a) + ε)) for some ε > 0, and af(n/b) ≤ cf(n) for some c < 1, then T(n) = Θ(f(n))

Common Examples:

  • Merge Sort: T(n) = 2T(n/2) + n -> O(n log n)
  • Binary Search: T(n) = T(n/2) + 1 -> O(log n)
  • Strassen's Algorithm: T(n) = 7T(n/2) + n² -> O(n^(log₂7))