Recurrence Relations & Master Theorem Flashcards
What is a recurrence relation?
A recurrence relation is a recursively-defined function
Suppose that the runtime of a program is T(n), then a recurrence relation will express T(n) in terms of its values at other, smaller values of n
What is the general pattern for recurrence?
Start from base case, use the recurrence to work out many cases by directly substituting and working upwards in values of n
Inspect results, then look for the pattern and make a hypothesis for the general results
Attempt to prove said hypothesis - using proof by induction
The extract the large n behaviour using big-Oh family
What is the Master Theorem’s General Formula?
T(n) = a T(n/b) + f(n)
What is case 1 for the Master Theorem?
T(n) is big-Theta(n^log_b(a)) if c < log_b(a)
What is case 2 for the Master Theorem?
T(n) is big-Theta(n^c * (log n)^(k+1)) if:
f(n) is big-Theta(n^c * (log n)^k) and c = log_b(a) & k >= 0
What is case 3 for the Master Theorem?
T(n) is big-Theta(f(n)) if f(n) is big-Omega with c > log_b(a) & f(n) satisfies the regularity condition:
a f(n/b) <= k(f(n)) for a k < 1