The Substitution Method for Solving Recurrences
Introduction
Many algorithms, especially Divide and Conquer algorithms, produce recurrence relations.
To determine the running time of these algorithms, we must solve the recurrence.
The Substitution Method is the most general of these methods because it can be applied to a wide variety of recurrences. However, unlike the Master Method, it requires us to first guess the form of the solution.
Why is it Called the Substitution Method?
The name comes from the key step in the proof.
Suppose the recurrence is
Assume that
for smaller values of .
Then we substitute this assumed bound into the recurrence:
Since we substitute the guessed solution into the recurrence, the technique is called the Substitution Method.
3. Steps in the Substitution Method
The substitution method consists of two steps:
Step 1
Guess the form of the solution using symbolic constants.
Step 2
Use mathematical induction to prove that the guess is correct and determine suitable values of the constants.
4. General Procedure
Suppose we have the recurrence
The procedure is
Step 1
Guess
Step 2
Assume
for all
This is the induction hypothesis.
Step 3
Substitute the induction hypothesis into the recurrence.
Step 4
Simplify the expression.
Step 5
Choose suitable constants so that the inequality holds.
Step 6
Verify the base case.
5. Example
Consider the recurrence
This is essentially the Merge Sort recurrence, except that it explicitly uses the floor function to ensure the recurrence is defined for integer values of n.
Step 1: Guess the Solution
Since the recurrence resembles Merge Sort,
we guess
Step 2: State the Induction Hypothesis
Instead of writing
we assume
for some constant
Notice that it does not use asymptotic notation inside the induction hypothesis. Instead, it uses an explicit constant c.
Step 3: Substitute
Using the induction hypothesis,
Substitute into the recurrence:
Step 4: Simplify
Since
and
we get
or
Step 5: Choose the Constant
The negative term
must dominate the hidden constant inside
Choose
large enough.
Then
Thus,
the induction step is complete.
Step 6: Base Case
Note that the base case must also satisfy the induction hypothesis.
Choose
and select
large enough so that
and
Hence,
the induction starts correctly.
Final Result
6. Making a Good Guess
The substitution method requires us to guess the form of the solution, but there is no general algorithm for finding the correct guess.
We can use several heuristics.
Heuristic 1: Compare with Familiar Recurrences
If a recurrence resembles one already solved, guess a similar solution.
Example:
Although the subproblem size is instead of , the recurrence still almost halves the problem size. Therefore, it is reasonable to guess
Heuristic 2: Narrow the Range
Find a simple lower bound and upper bound.
For example,
Clearly,
because the recurrence contains a linear term.
A loose upper bound such as
can often be established easily.
Then refine the guess until the upper and lower bounds meet at the correct answer, which here is
7. A Trick of the Trade: Subtracting a Lower-Order Term
Sometimes the correct guess seems to fail during induction.
Consider
Suppose we guess
Substitute:
which simplifies to
This does not imply
because of the extra constant term.
The Trick
Strengthen the induction hypothesis:
Instead of
assume
where
Substitute:
If
is chosen larger than the hidden constant in ,
then
The proof now works.
This emphasizes that subtracting a lower-order term often strengthens the induction hypothesis enough to make the algebra work.
8. Why Does This Trick Work?
Suppose the recurrence contains two recursive calls.
Every recursive call contributes
Therefore,
after substitution,
we obtain
instead of
The extra negative amount is used to absorb the positive constant outside the recursive calls.
9. Avoiding Pitfalls
One of the most important warnings is:
Never use asymptotic notation directly in the induction hypothesis.
Incorrect Proof
Suppose we write
Then,
This seems to prove
which is false for the Merge Sort recurrence.
Why?
Because the hidden constants inside the notation can change from one line to the next, making the argument invalid.
Correct Approach
Always write
or
with an explicit constant c.
This keeps the induction mathematically correct.
10. Advantages of the Substitution Method
-
Very general.
-
Works for recurrences that the Master Method cannot solve.
-
Provides rigorous proofs using induction.
-
Useful for establishing both upper and lower bounds.
11. Limitations
-
Requires a good initial guess.
-
Choosing the correct guess may require experience.
-
Induction proofs can involve careful manipulation of constants.
-
Often more algebraically intensive than the Master Method.
12. Summary
The Substitution Method is the most general technique for solving recurrences. It consists of two stages:
-
Guess the form of the solution.
-
Prove the guess by mathematical induction, substituting the induction hypothesis into the recurrence.
Important practical points:
-
Use explicit constants in the induction hypothesis rather than asymptotic notation.
-
If the proof fails because of a small additive term, strengthen the induction hypothesis by subtracting a lower-order term.
-
Verify both the induction step and the base cases.
-
Use recursion trees or previously solved recurrences to make an informed guess.
The substitution method is not only a technique for solving recurrences but also a powerful proof method that establishes asymptotic bounds rigorously. It complements the recursion tree method (which builds intuition) and the Master Method (which provides quick solutions for standard divide-and-conquer recurrences).
Comments
Post a Comment