For recurrent relation with the following format:
(T(n) = a T(frac{n}{b}) + f(n))
Let (c=log_b a) be the critical exponent. Master theorem compares the relative growth of (f(n)) and (n^{c}), specifically:
- if (exists epsilon gt 0), (f(n) in O(n^{c-epsilon})), which means (f(n)) is upper bounded by (n^c), then (T(n) in Theta(n^c));
- if (exists k geq 0, f(n) in Theta(n^c log^{k}n)), which means (f(n)) grows in the same order as (n^c log^k n), then, (f(n) in Theta(n^c log^{k+1}n))
- if (exists epsilon gt 0), (f(n) in Omega(n^{c+epsilon})) and (exists c<1, a f(frac{n}{b}) < cf(n)) for all sufficiently large (n), then (T(n) in Theta(f(n)))
Some examples:
- (T(n) = 3T(n/2) + n^2)
- (T(n) = 4T(n/2) + n^2)
- (T(n) = 10T(n/3) + n^2)
- (T(n) = 2T(n-1) + 1) Tower of Hanio
- (T(n) = T(sqrt{n}) + 1)
- (T(n) = 2T(n/2) + nlog n)
Relation 4) and 5) cannot be solved by master theorem, but could be solved by iterated substitution.
This is a test of markdown
(T(n) = O(n) + frac{1}{n} sum_{k=1}^{n}T(n-k))
iterated substitution: