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

Module 1 Part E

The document focuses on analyzing recursive algorithms, specifically through methods such as substitution, recursion trees, and the master method. It provides examples of recurrence relations and their solutions, illustrating the amount of work done in recursive calls. Additionally, it includes sections for checking progress and important results related to decreasing functions.
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)
3 views11 pages

Module 1 Part E

The document focuses on analyzing recursive algorithms, specifically through methods such as substitution, recursion trees, and the master method. It provides examples of recurrence relations and their solutions, illustrating the amount of work done in recursive calls. Additionally, it includes sections for checking progress and important results related to decreasing functions.
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/ 11

Amity School of Engineering & Technology (CSE)

Analysis and Design of Algorithm(ADA)

Module-1
Analyzing Recursive algorithm

1
Amity School of Engineering & Technology (CSE)

OBJECTIVES
After completing this section, you will be able to

 Analyse recursive algorithms

2
Amity School of Engineering & Technology (CSE)

3
Amity School of Engineering & Technology (CSE)

Analyse Recursive algorithm


• Idea
Solving Recurrences
using
Recursive Recurrence  Substitution Method
Program Relation  Recursion tree method
 Master Method etc.

Time complexity

4
Amity School of Engineering & Technology (CSE)

Example1:
------ T(n) Amount of work done is
nothing but number of
function calls.
For ‘n’ it makes (n+1) calls

----- 1 unit
and print ‘n’ times.

----- T(n-1)
For Example: n=3, we have
fun(3), fun(2), fun(1) and
fun(0) calls=> n+1calls=O(n)
----------------------------
T(n)=T(n-1)+1
Recurrence relation:

𝑇 ( 𝑛 )=
{ 1 𝑛=0
𝑇 ( 𝑛 − 1 ) +1 𝑛> 0
5
Amity School of Engineering & Technology (CSE)

Using Back substitution:

……..

6
Amity School of Engineering & Technology (CSE)

Example2:
------ T(n)

--- 1

--- n+1

--- n

----- T(n-1)

----------------------------
T(n)=T(n-1)+2n+2=T(n-1)+O(n)
Recurrence relation:
𝑇 ( 𝑛 )=
{ 1𝑛=0
𝑇 ( 𝑛 − 1 ) +𝑛 𝑛> 0 7
Amity School of Engineering & Technology (CSE)

Using Back substitution:

……..

8
Amity School of Engineering & Technology (CSE)

Check your progress

Ex.1: Ex.2:

9
Amity School of Engineering & Technology (CSE)

Important results [Decreasing function]:

Sr No. Recurrence Solution

1.

2.

3.

4.
5. ???

10
Amity School of Engineering & Technology (CSE)

Master Method [Decreasing function]:

Where
Case1
Case2
Case3

Example Recurrence Relation Solution


1
2
3

11

You might also like