Recurrence equations #

Created Thu May 9, 2024 at 7:34 AM

This chapter offers three methods for solving recurrences—that is, for obtaining asymptotic “theta” or “O” bounds on the solution:


Substitution method #

  1. Form a recurrence relation
  2. Guess a expression for the complexity
  3. Try to prove the guessed using induction
  4. Fixes/tweaks
    1. If you get an off by 1 error, or similar, subtract a lower order term in the expression. This usually makes the math work out.
    2. Changing variables - algebraic manipulation can help. Sometimes you may need multiple manipulations to convert an “unknown” looking equation to a known one.

Recursion-tree method #

Use this when you have trouble guessing (i.e. the backbone of the substitution method).

A recursion tree is best used to generate a good guess, which you can then verify by the substitution method. But if we are very careful and accurate in making the tree, that itself can serve as the proof.

Sloppiness is tolerable in this method since it’s not exact induction. Usual examples are assuming exact powers (of 2), taking infinite GP (instead of finite GP) to have simpler sum expression, etc.

Master method #

The master method provides a “cookbook” method for solving recurrences of the form T(n) = aT(n/b) + f(n), where a >= 1, b > 1 are constants and f(n) is an asymptotically positive function.

To use the master method, you will need to memorize three cases, but then you will be able to solve many recurrences quite easily, often without pencil and paper.

Intuition (enough MAID):

Master theorem will not be applicable if:

  1. The comparison differs non-polynomially. i.e. for very small exponent delta or some non polynomial multiplier etc. i.e. it’s the case between the gaps of case 1-2 or 2-3.
  2. Its case 3 but the regularity condition does not hold.