The substitution method applies induction to find the asymptotic bounds for a given recurrence. It comprises two main steps:

  • We guess the form of the solution using symbolic constants (inductive hypothesis).
  • Use induction to show that the solution works (inductive step), then find the constants.

Process

Given a particular recurrence , we make a guess for its running time. It’s better to prove big-O and big-Ω separately before proving big-Θ.

For example, say we assume , for .

  • We adopt the inductive hypothesis that , for all .
  • Assume by induction that this bound holds for all numbers at least as big as and less than . Therefore:
    • If , it holds for at least .
  • This yields .
  • We substitute this into the recurrence, which yields: , as required.
  • Then, we have to define and , which shouldn’t be too difficult.
  • Then, we prove the base case. We perhaps ought to define the lowest recursive term manually, so that we don’t accidentally go too far or suggest a term takes time, because this can never happen (CPU cycles).