Recurrences

Overview

A recurrence is an equation that describes a function in terms of its value on other, typically smaller, arguments. A recurrence T(n) is algorithmic if, for every sufficiently large threshold constant n0>0, the following two properties hold:

  1. For all n<n0, we have T(n)=Θ(1).
  2. For all nn0, every path of recursion terminates in a defined base case.

Finding Bounds

Substitution

In the substitution method, one guesses the form of a bound and then uses mathematical induction to prove the guess correct and solve for constants. In general, there are two steps:

  1. Guess the form of the solution using symbolic constants.
  2. Use mathematical induction to show the solution works and find the constants.

Recursion-Tree

In the recursion-tree method, one models the recurrence as a tree whose nodes represent the costs incurred at various levels of the recursion. To then solve the recurrence, one determines the costs at each level and adds them up.

Generally speaking, once a reasonable guess has been derived, the substitution method is then used to formally prove the result.

Master Theorem

Let a>0 and b>1 be constants. Recurrences of form T(n)=aT(n/b)+f(n) are called master recurrences. The f(n) term is called the driving function.


Let a>0 and b>1 be constants, and let f(n) be a driving function that is defined and nonnegative on all sufficiently large reals. Define the recurrence T(n) on nN by

T(n)=aT(n/b)+f(n),

where aT(n/b) actually means a1T(n/b)+a2T(n/b) for some constants a10 and a20 satisfying a=a1+a2. Then the asymptotic behavior of T(n) can be characterized as follows:

  1. If there exists a constant ϵ>0 such that f(n)=O(nlogbaϵ), then T(n)=Θ(nlogba).
  2. If there exists a constant k0 such that f(n)=Θ(nlogbalgkn), then T(n)=Θ(nlogbalgk+1n).
  3. If there exists a constant ϵ>0 such that f(n)=Ω(nlogba+ϵ), and if f(n) additionally saitisfies the regularity condition af(n/b)cf(n) for some constant c<1 and all sufficiently large n, then T(n)=Θ(f(n)).

Solving Recurrences

To solve a recurrence relation means to find a closed form for the relation (with respect to initial conditions).

Telescoping

We can use telescoping to solve recurrences of form an=an1+f(n) by noticing that:

a1a0=f(1)a2a1=f(2)anan1=f(n)ana0=k=1nf(n)

Iteration

Iteration refers to the expansion of terms, starting at the initial conditions, in the hope of discovering a pattern. It is more general than telescoping is.

A recurrence of form an=an1+f(n) can be solved with iteration like so:

a1=a0+f(1)a2=(a0+f(1))+f(2)an=((a0+f(1))+f(2))+)+f(n)an=a0+k=1nf(n)

Characteristic Roots

When encountering linear homogeneous recurrence relations with constant coefficients, we can use the characteristic root technique to solve. We demonstrate with a quadratic characteristic polynomial, though this technique generalizes to higher-order polynomials as well.

Given recurrence relation an+αan1+βan2=0, the characteristic polynomial is r2+αr+β. If r1 and r2 are distinct roots of the characteristic polynomial, then the solution to the recurrence relation is

an=ar1n+br2n

where a and b are determined by the initial conditions. If the characteristic polynomial only has one root r, the solution is instead

an=arn+bnrn.
Powered by Forestry.md