Recurrence Relation
Recurrence Relation
The running time for a recursive algorithm is most easily expressed by a recursive expression
because the total time for the recursive algorithm includes the time to run the recursive call(s).
A recurrence relation defines a function by means of an expression that includes one or more
(smaller) instances of itself. A classic example is the recursive definition for the factorial
function:
From this definition, the first seven numbers of the Fibonacci sequence are
Notice that this definition contains two parts: the general definition for Fib(n)Fib(𝑛) and the
base cases for Fib(1)Fib(1) and Fib(2)Fib(2). Likewise, the definition for factorial contains a
recursive part and base cases.
Recurrence relations are often used to model the cost of recursive functions. For example, the
number of multiplications required by a recursive version of the factorial function for an input
of size n𝑛 will be zero when n=0𝑛=0 or n=1𝑛=1 (the base cases), and it will be one plus the
cost of calling fact on a value of n−1𝑛−1. This can be defined using the following recurrence:
Substitution Method
The substitution method for solving recurrences is famously described using two steps:
Example: Determine a tight asymptotic lower bound for the following recurrence:
𝑇(𝑛)=4𝑇(𝑛/2)+𝑛2
T(n)=Ω(cn2lg(n))
Example: