Substitution Method in Design and Analysis
of Algorithms (DAA)
Presented by:
Ayusman Mishra
Registration No:230301120258, 4th Semester, CSE.
Biswaranjan Mohanty
Registration No:230301120263, 4th Semester, CSE.
Shibananda Swain
Registration No:230301120290, 4th Semester, CSE.
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
SCHOOL OF ENGINEERING AND TECHNOLOGY, CENTURION UNIVERSITY,
BHUBANESWAR, ODISHA
Contents :
1.Introduction
2.Steps of Substitution Method
3.Substitution Method Types
4.Example 1
5.Proof using Induction
6.Example 2
7.Limitations
8.Conclusion
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
SCHOOL OF ENGINEERING AND TECHNOLOGY, CENTURION UNIVERSITY,
BHUBANESWAR, ODISHA
Introduction
The Substitution Method is used to solve recurrence
relations.
It involves guessing a bound and using mathematical
induction to prove it.
Useful for analyzing divide-and-conquer algorithms.
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
SCHOOL OF ENGINEERING AND TECHNOLOGY, CENTURION UNIVERSITY, 3
BHUBANESWAR, ODISHA
Steps of Substitution Method
Steps:
▪ Guess the solution: Based on the form of the recurrence,
make an educated guess about the solution.
▪ Prove by induction: Use induction to prove that the
guessed solution holds for all values of n.
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
4
SCHOOL OF ENGINEERING AND TECHNOLOGY, CENTURION UNIVERSITY,
BHUBANESWAR, ODISHA
Substitution Method: There are two types of substitution methods-
❑ Forward Substitution: It is called Forward Substitution because here we substitute the
recurrence of any term into the next term. It uses the following steps to find Time using
recurrences-
▪ Pick the Recurrence Relation and the given initial Condition
▪ Put the value from the previous recurrence into the next recurrence
▪ Observe and Guess the pattern and the time
▪ Prove that the guessed result is correct using Mathematical Induction.
❑ Backward Substitution: It is called backward substitution because here, we substitute the
recurrence of any term with previous terms. It uses the following steps to find Time using
recurrences-
▪ Take the main recurrence and try to write recurrences of previous terms
▪ Take just the previous recurrence and substitute it with the main recurrence
▪ Again, take one more previous recurrence and substitute it with the main recurrence
▪ Do this process until you reach the initial condition
▪ After this substitute the value from the initial condition and get the solution 5
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
SCHOOL OF ENGINEERING AND TECHNOLOGY, CENTURION UNIVERSITY, BHUBANESWAR, ODISHA
Recurrence Relations: Forward-Substitution Method
1. Pick Recurrence and the given initial Condition: T(n)=T(n-1)+n, n>1. T(n)=1, n=1
2. Put the value from the previous recurrence into the next recurrence:
T(1) = 1. T(2) = T(1) + 2 = 1 + 2 = 3. T(3) = T(2) + 3 = 1 + 2 + 3 = 6. T(4)= T(3) + 4 = 1 + 2 + 3 + 4 =
10.
3. Observe and Guess the pattern and the time: So, the guessed pattern will be T (n) = 1 + 2 + 3 .... + n =
(n * (n+1))/2.
Time Complexity will be O(n2).
4. Prove that the guessed result is correct using mathematical Induction: Prove T(1) is true:
T(1) = 1 * (1+1)/2 = 2/2 = 1 and from definition of recurrence we know T(1) = 1. Hence proved T(1) is
true
Assume T(N-1) to be true: Assume T(N-1) = ((N - 1) * (N-1+1))/2 = (N * (N-1))/2 to be true
Then prove T(N) will be true: T(N) = T(N-1) + N from recurrence definition
Now, T(N-1) = N * (N-1)/2
So, T(N) = T(N-1) + N
= (N * (N-1))/2 + N
= (N * (N-1) + 2N)/2
=N * (N+1)/2And from our guess also T(N)=N(N+1)/2
Hence T(N) is true. Therefore,
DEPARTMENT ourOFguess was correct
COMPUTER and the
SCIENCE time will be O(N2)
& ENGINEERING
6
SCHOOL OF ENGINEERING AND TECHNOLOGY, CENTURION UNIVERSITY, BHUBANESWAR, ODISHA
Recurrence Relations: Back-Substitution Method
Now we will use these steps to solve a problem. The problem is- T(n) = T(n-1) + n, n>1T(n) =
1, n = 1
1. Take the main recurrence and try to write recurrences of previous terms: T(n) = T(n-1) + n.
T(n-1) = T(n-2) + n – 1. T(n-2) = T(n-3) + n - 2
2. Take just the previous recurrence and substitute into the main recurrence: Put T(n-1) into
T(n)So, T(n)=T(n-2)+ n-1 + n
3. similarly, take one more previous recurrence and substitute into the main recurrence: Put T(n-
2) into T(n)So,
T(n)=T(n-3)+ n-2 + n-1 + n.
4. Do this process until you reach the initial condition. So, we can find T(n-3), T(n-4)......and so
on and can insert into
T(n). Eventually we will get following: T(n)=T(1) + 2 + 3 + 4 +.........+ n-1 + n
5. After this substitute the value from the initial condition and get the solution Put T(1)=1, T(n)
= 1 +2 +3 + 4 +..............+ n-1
+ n = n(n+1)/2. So, Time will be O(N2).
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
7
SCHOOL OF ENGINEERING AND TECHNOLOGY, CENTURION UNIVERSITY,
BHUBANESWAR, ODISHA
Recurrence Relations: Substitution Method Example
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING 8
Recurrence Relations: Substitution Method Example
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
9
SCHOOL OF ENGINEERING AND TECHNOLOGY, CENTURION UNIVERSITY,
BHUBANESWAR, ODISHA
Conclusion
-The Substitution Method is a powerful tool for solving
recurrences.
- Helps analyze divide-and-conquer algorithms.
- Often used alongside other methods for verification
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
10
SCHOOL OF ENGINEERING AND TECHNOLOGY, CENTURION UNIVERSITY,
BHUBANESWAR, ODISHA
THANK
YOU…
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
11
SCHOOL OF ENGINEERING AND TECHNOLOGY, CENTURION UNIVERSITY,
BHUBANESWAR, ODISHA