Skip to content

Master Theorem

Given a recurrence relation in the form of:

\[ T(n) = a\cdot T\left( \frac{n}{b} \right) + n^{d} \]

We can solve it using the master theorem.

We start by first calculating \(\log_{b} a\), followed by looking at the cases.

  • \(\log_{b} a > d\)
    • \(T(n) \in \Theta(n^{\log_{b} a})\)
  • \(\log_{b}a < d\)
    • \(T(n) \in \Theta(n^{d})\)
  • \(\log_{b}a = d\)
    • \(T(n) \in \Theta(n^{d} \log n)\)

Warning

There's a more generalised version that solves recurrences in the form of:

\[ T(n) = aT\left( \frac{n}{b} \right) + n^{d}\log ^{p}(n) \]

Hopefully you won't need this (?). Nonetheless, if you need it, the cases are in this video.