0% found this document useful (0 votes)
80 views14 pages

Lecture 1.1.3

1. The document discusses various methods for solving recurrence relations: substitution method, iteration method, recursion tree method, and master's theorem. 2. The substitution method involves guessing a solution and using mathematical induction to prove it is correct. The iteration method expands the recurrence into a summation. The recursion tree method uses a tree diagram to represent iterations. 3. The master's theorem can solve recurrences of the form T(n)=aT(n/b)+θ(nk) by comparing a and bk and applying one of three cases to determine the solution type.

Uploaded by

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

Lecture 1.1.3

1. The document discusses various methods for solving recurrence relations: substitution method, iteration method, recursion tree method, and master's theorem. 2. The substitution method involves guessing a solution and using mathematical induction to prove it is correct. The iteration method expands the recurrence into a summation. The recursion tree method uses a tree diagram to represent iterations. 3. The master's theorem can solve recurrences of the form T(n)=aT(n/b)+θ(nk) by comparing a and bk and applying one of three cases to determine the solution type.

Uploaded by

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

University Institute of Engineering

DEPARTMENT OF COMPUTER SCIENCE


& ENGINEERING
Bachelor of Engineering (Computer Science & Engineering)
Subject Name : Data Structures & Algorithm Analysis

Subject Code:21CST-260

DISCOVER . LEARN . EMPOWER


Agenda
• Recurrence Relation
• Recurrence Relation Types
Recurrence Relation
A recurrence is an equation or inequality that describes a function in terms of its values on
smaller inputs. To solve a Recurrence Relation means to obtain a function defined on the
natural numbers that satisfy the recurrence.
There are four methods for solving Recurrence:

1. Substitution Method
2. Iteration Method
3. Recursion Tree Method
4. Master Method
Substitution
The Substitution Method Consists of two main steps:
Method
1. Guess the Solution.
2. Use the mathematical induction to find the boundary condition and shows that the guess is
correct.
Iteration Methods
It means to expand the recurrence and express it as a summation of terms of n and initial
condition.
Recursion Tree Method
1. Recursion Tree Method is a pictorial representation of an iteration method which is in the form of a tree
where at each level nodes are expanded.

2. In general, we consider the second term in recurrence as root.

3. It is useful when the divide & Conquer algorithm is used.

4. It is sometimes difficult to come up with a good guess. In Recursion tree, each root and child represents the
cost of a single subproblem.

5. We sum the costs within each of the levels of the tree to obtain a set of pre-level costs and then sum all pre-
level costs to determine the total cost of all levels of the recursion.

6. A Recursion Tree is best used to generate a good guess, which can be verified by the Substitution Method.
Example 1

We have to obtain the asymptotic bound using recursion tree method.

Solution: The Recursion tree for the above recurrence is


Master Theorem
Master’s Theorem is a popular method for solving the recurrence relations.
Master’s theorem solves recurrence relations of the form-
Master Theorem Cases
To solve recurrence relations using Master’s theorem, we compare a with bk.
Then, we follow the following cases-
Case-01: If a > bk, then T(n) = θ (nlogba)
Case-02: If a = bk and
● If p < -1, then T(n) = θ (nlogba)
● If p = -1, then T(n) = θ (nlogba.log2n)
● If p > -1, then T(n) = θ (nlogba.logp+1n)

Case-03: If a < bk and


● If p < 0, then T(n) = O (nk)
● If p >= 0, then T(n) = θ (nklogpn)
Problem-01:
Solve the following recurrence relation using Master’s theorem-
T(n) = 3T(n/2) + n2

Solution-
We compare the given recurrence relation with T(n) = aT(n/b) + θ (nklogpn).
Then, we have-
a=3b=2k=2p=0
Now, a = 3 and bk = 22 = 4.
Clearly, a < bk.
So, we follow case-03.
Since p = 0, so we have-
T(n) = θ (nklogpn)
T(n) = θ (n2log0n)
Thus, T(n) = θ (n2)
References
1. Lipschutz, S., “Data Structures, Schaum's Outline Series”, 2nd edition (2014), Tata
McGraw Hill.
2. Cormen, Leiserson, Rivest, Stein, “Introduction to Algorithms”, 3rd edition, Prentice
Hall of India.
3. Levitin, “Introduction to the design and analysis of algorithms”, 2nd edition, Pearson.
4. Baase, Van Gerder, “Computer Algorithms: Introduction to Design Analysis”, 3rd
edition, Pearson.
5. Horowitz, Sahni and Rajasekaran, “Fundamental of Computer, Algorithms”, University
Press (India).
6. https://www.tutorialspoint.com/discrete_mathematics/discrete_mathematics_recurrence
_relation.htm
Thank You

You might also like