Learn to solve recurrence relations and find asymptotic complexity of decreasing and dividing functions using master theorem. See online demo.
Master theorem provides an asymptotic analysis (using Big O notation) for recurrence relations that occur in the analysis of many divide and conquer algorithms. The approach was first presented by Jon Bentley, Dorothea Haken, and James B. Saxe in 1980, where it was described as a "unifying method" for solving such recurrences. The name "master theorem" was popularized by the widely used algorithms textbook Introduction to Algorithms by Cormen, Leiserson, Rivest, and Stein.
T(n) = aT(n/b) + f(n) where
- a ≥ 1,
- b > 1, and
- f(n) = Θ(nk logp n), where k ≥ 0 and p ≥ 0
- if p > -1 then Θ(nk logp+1 n)
- if p = -1 then Θ(nk log log n)
- if p < -1 then Θ(nk)
- if p > 0 then Θ(nk logp n)
- if p ≤ 0 then Θ(nk)
T(n) = aT(n - b) + f(n) where
- a > 0,
- b > 0, and
- f(n) = Θ(nk logp n), where k ≥ 0 and p ≥ 0
The code is open-sourced, licensed under the MIT license.