There are three solutions to solve the recurrences.
Substitution method:
1. Guess the form of the solution
2. Verify by induction
3. Slove for consts
Recursion-tree method:
1. Count the height
2. Count the leaves.
3. Total: level by level
The master method:
The master method applies to recurrences of the form T(n) = aT(n/b) + f (n), where a ≥ 1, b > 1, and f is asymptotically positive.
Method:Compare f (n) with n^log(b)a:
case1: f(n) = O(n^[log(b)a – ε]) for some constant ε > 0.
Explain: f(n) grows polynomially slower than n^log(b)a (by an n^ε factor).
Solution: T(n) = Θ(n^log(b)a) .
Ex: T(n)=4T(n/2)+n ---------- a=4,b=2,f(n)=n.
n^log(b)a=n^2, f(n)=n=O(n^2), So the T(n)=Θ(n^2)
case2: f(n) = Θ(n^log(b)a*(lgn)^k) for some constant k ≥ 0.
Explain: f(n) and n^log(b)a grow at similar rates.
Solution: T(n) = Θ(n^log(b)a*(lgn)^(k+1)).
Ex: T(n)=4T(n/2)+n^2 ---------- a=4,b=2,f(n)=n^2.
n^log(b)a=n^2, f(n)=n^2=Θ(n^2*(lgn)^0), So the T(n)=Θ(n^2*lgn)
case3: f(n) = Ω(n^[log(b)a + ε]) for some constant ε > 0.
and f(n) satisfies the regularity condition that af(n/b) ≤ cf(n) for some constant c < 1.
(Under this condition, it can make sure that the consts decrease geometrically, Dominate: f(n))
Explain: f(n) grows polynomially faster than nlogba (by an n^ε factor),
Solution: T(n) = Θ(f (n)) .
Ex: T(n)=4T(n/2)+n^3 ---------- a=4,b=2,f(n)=n^3.
n^log(b)a=n^2, f(n)=n^3=Ω(n^2), So the T(n)=Θ(n^3)