0% found this document useful (0 votes)
3 views10 pages

Recurrence Relations

The document explains the substitution method for solving recurrence relations, detailing steps such as expanding the recurrence, identifying patterns, and deriving a closed-form solution. It also discusses the advantages and disadvantages of the method, noting its effectiveness for logarithmic and polynomial-time recurrences, while acknowledging challenges with complex forms. Additionally, it introduces the Master’s Theorem for solving recurrence relations and provides practice questions for further understanding.

Uploaded by

dukipadhai69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views10 pages

Recurrence Relations

The document explains the substitution method for solving recurrence relations, detailing steps such as expanding the recurrence, identifying patterns, and deriving a closed-form solution. It also discusses the advantages and disadvantages of the method, noting its effectiveness for logarithmic and polynomial-time recurrences, while acknowledging challenges with complex forms. Additionally, it introduces the Master’s Theorem for solving recurrence relations and provides practice questions for further understanding.

Uploaded by

dukipadhai69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Recurrence Relations

and
How to Solve Them

By Ms. Rashmi Yadav


Substitution Method for Solving
Recurrence Relations
De nition
The substitution method is a technique used to solve recurrence relations by expanding the
recurrence step by step and then identifying a pattern to derive a general formula. The method
typically involves:

1. Expanding the recurrence multiple times.

2. Identifying a pattern in the expansion.

3. Finding the stopping condition (base case).

4. Substituting back to derive the nal closed-form expression.

5. Proving the solution using induction (optional but useful for correctness).
fi
fi
Steps in the Substitution Method
Step 1: Expand the Recurrence
• Substitute the recurrence equation into itself multiple times to express T(n) in terms of smaller instances.

Step 2: Identify the Pattern


• Observe the structure of terms as the recurrence expands.
• Identify how the function breaks down and the pattern it follows.

Step 3: Find the Stopping Condition (Base Case)


• Determine when the recurrence reaches the base case (usually T(1) or another constant).
• Express the total number of steps k needed to reach the base case in terms of n.

Step 4: Substitute and Solve


• Express T(n) as a function of k and the base case.
• Replace k with its expression in terms of n to get the nal formula.

Step 5 (Optional): Prove by Induction


• If needed, verify the correctness of the derived formula using mathematical induction.
fi
Example 1: Simple Recurrence
Solve:
T(n) = T(n/2) + O(1)

Step 1: Expand the Recurrence Step 2: Find Stopping Condition

T(n) = T(n/2) + 1 Stop when n/2k = 1, so:


T(n) = T(n/4)+ 1 + 1 n = 2k -> k = log2 n
T(n) = T(n/8) + 1 + 1 + 1
Step 3: Final Expression
After k steps:
T(n) = T(n/2k) + k T(n) = T(1) + log2 n

Since T(1) is a constant, we get:


T(n) = O(log n)
Advantages and Disadvantages

Advantages of the Substitution Method


• Works well for recurrences with simple patterns.
• Helps understand the step-by-step growth of the function.
• Can be used to prove solutions using induction.

Disadvantages
• Can be tedious for complex recurrences.
• Not always easy to identify the pattern.
• Sometimes requires additional assumptions for simpli cations.
fi
Conclusion

The substitution method is a useful tool for

• solving recurrence relations by expanding them step by step,

• identifying patterns, and

• deriving a closed-form solution

• e ective for logarithmic and polynomial-time recurrences

• may be di cult for more complex forms requiring other techniques like the Master Theorem or
recursion trees.
ff
ffi
Master’s Theorem
for Solving Recurrence Relations
Examples Shortcut
• Recurrence relation is of the form Case 1: T(n) = 2T(n/2) + 1
a = 2, b = 2, and f(n) = 1 = θ(n0log0n)
T(n) = aT(n/b) + f(n) • logba > k, then answer is θ(nlogba) k = 0, and logba = log22 =1
=>1>0
a>=1, b>1 and f(n) = θ(nklogpn) θ(n)
Case 2: T(n) = 2T(n/2) + n f(n)*logn
a = 2, b = 2, and f(n) = n = θ(n1log0n)
• logba = k k = 1, and logba = log22 =1
• Find logba and k ➡If, p > -1, then answer is θ(nk logp+1n) logba = k and p = 0 => θ(n logn)

➡If, p = -1, then answer is θ(nk loglogn) T(n) = 2T(n/2) + n/logn


a = 2, b = 2, and f(n) = n/logn = θ(n1log-1n)
k = 1, and logba = log22 =1
logba = k and p = -1 => θ(n loglogn)

➡If, p < -1, then answer is θ(nk) T(n) = 2T(n/2) + nlog-2n


a = 2, b = 2, and f(n) = nlog-2n
= θ(n1log-2n)
k = 1, and logba = log22 =1
logba = k and p = -2 => θ(n)

Case 3: T(n) = T(n/2) + n2 f(n)


a = 1, b = 2, and f(n) = n2 = θ(n2log0n)
• logba < k k = 2, and logba = log21 = 0
➡If, p >= 0, then answer is θ(nk logpn) logba < k and p = 0 => θ(n2)

➡If, p < 0, then answer is O(nk) T(n) = T(n/2) + n3/logn


a = 1, b = 2, and f(n) = n3/logn = θ(n3log-1n)
k = 3, and logba = log21 = 0
logba < k and p = -1 => θ(n3)
Practice Questions
1. T(n) = 4T(n/2) + n

2. T(n) = 8T(n/2) + n

3. T(n) = 9T(n/3) + 1

4. T(n) = 8T(n/2) + nlogn

5. T(n) = 9T(n/3) + n2

6. T(n) = T(n/2) + n2logn

7. T(n) = 4T(n/2) + n3

You might also like