Recurrence Relations
Recurrence Relations
and
How to Solve Them
5. Proving the solution using induction (optional but useful for correctness).
fi
fi
Steps in the Substitution Method
Step 1: Expand the Recurrence
• Substitute the recurrence equation into itself multiple times to express T(n) in terms of smaller instances.
Disadvantages
• Can be tedious for complex recurrences.
• Not always easy to identify the pattern.
• Sometimes requires additional assumptions for simpli cations.
fi
Conclusion
• may be di cult for more complex forms requiring other techniques like the Master Theorem or
recursion trees.
ff
ffi
Master’s Theorem
for Solving Recurrence Relations
Examples Shortcut
• Recurrence relation is of the form Case 1: T(n) = 2T(n/2) + 1
a = 2, b = 2, and f(n) = 1 = θ(n0log0n)
T(n) = aT(n/b) + f(n) • logba > k, then answer is θ(nlogba) k = 0, and logba = log22 =1
=>1>0
a>=1, b>1 and f(n) = θ(nklogpn) θ(n)
Case 2: T(n) = 2T(n/2) + n f(n)*logn
a = 2, b = 2, and f(n) = n = θ(n1log0n)
• logba = k k = 1, and logba = log22 =1
• Find logba and k ➡If, p > -1, then answer is θ(nk logp+1n) logba = k and p = 0 => θ(n logn)
2. T(n) = 8T(n/2) + n
3. T(n) = 9T(n/3) + 1
5. T(n) = 9T(n/3) + n2
7. T(n) = 4T(n/2) + n3