Method 1: Unrolling the recurrence

  • “Opening up” the recurrences step-by-step
  • Doesn’t need any idea about the final answer!

Revisiting the recurrence of MergeSort

Unrolling the recurrence .
We first write this recurrence explicitly as follows: for some constant

  • for each for some constant (by definition of big )
  • Best Case:

Three steps to solve this recurrence:

  • Analyse the first few levels level 0, level 1, level 2,
  • Identify a pattern seems to be doing work at each level
  • Sum up over all levels of recursion If I have levels, then Size of base case = 2 . So total work is

Another example

Merge Sort .
New Example = are constants

Level below it

At level , I have instances each having size .
Base Case

  • How many Levels?
    • If I have levels, then size at level = size of base case =

At level , we do .
Total levels .
Total work done

Method 2: Verifying by substitution in the recurrence

  • Works if you already have a guess for the running time!
  • Check (by induction) whether your guess is satisfied by the recurrence.

We first write this recurrence explicitly as follows: for some constant

  • for each for some constant (by definition of big )
  • Best Case:

Suppose we believe that is true, and we want to verify it!

Proof by induction using susbtitution

  • Base case is
  • Inductive Hypothesis
    • For each we have
  • Inductive Step:

Note

By this method, we have verified that is one possible solution for this recurrence. Unlike the previous method of unrolling, this might lead to just verifying that a much higher running time is correct!