Recurrence

A recurrence is in standard form if it is written as . For some constants , and some function

  • the branching factor of the tree (how many children)
  • the reduction factor (length compare to main)
  • : the time complexity of non-recursive work
  • The height of the tree is
  • The number of vertices at level is
  • The total non-recursive work done at level is
    • Root Work.
    • Leaf Work.
  • Summing up the levels, the total amount of work done is

Master Theorem

We always use Master Theorem to solve such standard form; Let , then there are three cases defined by the leaf work:

  1. Leaf heavy: for some constant

  2. Balanced:

  3. Root heavy: for some constant , and for some constant for all sufficiently large (Regularity Condition)

Combine those cases, we have:

Base on this, we:

  1. Write the recurrence in normal form to find the parameters
  2. Compare to to determine the case split
  3. Read off the asymptotics from the relevant case

Simplified Master Theorem: let

Generally

For a recurrences, we can simply use to judge the time complexity. For example, the Fibonacci:

  • Assume the time complexity of is , and has time complexity of and
  • then we have

To prove :

First prove

  1. Remove all the floors and ceilings from the recurrence
  2. Make a guess for such that
  3. write out the recurrence:
  4. whenever appears on the RHS of the recurrence, substitute it with
  5. Try to prove
  6. Pick to make your analysis work

Then use the same way to prove

Correctness

When we have a function, how can we show the function we write is correct?

Formally, we define the input and output, and try to prove input output

That is, after we have the definition of input and out, then we do following to prove a function’s correctness:

  1. define loop invariant
  2. Initialization
  3. Maintenance(inductive step)
  4. Termination
  5. Descending sequence

Actually, this part is the most tough part of the course where sometimes hard to find a intuitive way to prove correctness.