SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Department of Information Technology
Subject: . Design and Analysis of Algorithm
Topic:- Recurrence Relations
TAE:2
Submitted by:
Soumya Srinivas-03
Pratiksha Mohod-13
Samiksha Khanorkar-18
Guided by:- Prof. Kapil K. Wankhade
Recurrence Relations
A recurrence relation for a sequence { 𝑎 𝑛 } is an
equation that expresses 𝑎 𝑛 in terms of one or more of
the previous terms in the sequence,
𝑎0, 𝑎1, . . . , 𝑎 𝑛+1
For all integers n ≥ 𝑎0 where 𝑎0 is a nonnegative
integer.
A sequence is called a solution of a recurrence relation
if its terms satisfy the recurrence relation.
• Consider the example of Fibonacci numbers
F(n) = F(n − 1) + F(n − 2)
F(1) = 1
F(0) = 1
Recurrence Relations
In the Fibonacci numbers we needed two initial conditions,
F(0) =1 and F(1) = 1 since F(n) was defined by the two previous
terms in the sequence.
• Generally, recurrences can have the form
T(n) = aT ( n/b) + f(n)
Recurrence relations have two parts: recursive terms and non-
recursive terms.
Recurrence Relations
T(n) = 2T(n − 2) + 𝒏 𝟐 − 10
Recursive Non-Recursive
Recursive terms come from when an algorithm calls itself.
Non-recursive terms correspond to the “non-recursive” cost of
the algorithm work the algorithm performs within a function.
Solving Recurrence Relations
• Homogeneous Mode
Consider the recurrence relation
T(n) + aT(n − 1) + bT(n − 2) = 0
The idea for solving this relation is to “guess” a solution of the
form T(n) = x n
Since T(n − 1) = 𝑥 𝑛−1 and T(n − 2) = 𝑥 𝑛−2 we get the equation
x n + axn−1 + bxn−2 = 0
Since x is clearly not zero, we can divide by 𝑥 𝑛−2
to get
𝑥2 + ax + b = 0
If this equation factors as (x−𝑟1) (x−𝑟2) = 0
with 𝑟1≠ 𝑟2 (so that the characteristic equation has two
distinct roots), then the general solution is
T(n) = 𝒄 𝟏. 𝒓 𝟏
𝒏+ 𝒄 𝟐. 𝒓 𝟐
𝒏
Since x is clearly not zero, we can divide by 𝑥 𝑛−2 to get
𝑥2 + ax + b = 0
Solving Recurrence Relations
Solving Recurrence Relations
Example . Solve the recurrence relation
T(n) − 4T(n − 1) + 3T(n − 2) = 0
T(0) = 0
T(1) = 2
Solution: The characteristic equation is
𝑥2 − 4x + 3 = 0,
or
(x − 3)(x − 1) = 0,
so the general solution is,
T(n) = 𝒄 𝟏 3 𝑛 + 𝒄 𝟐 1 𝑛
T(n) = 𝒄 𝟏 3 𝑛 + 𝒄 𝟐.
To find 𝒄 𝟏 and 𝒄 𝟐 we plug in the initial conditions
to get two equations in those two variables:
0 = T(0) = 𝒄 𝟏 30
+ 𝒄 𝟐
T(0) =𝒄 𝟏+ 𝒄 𝟐
2 = T(1) = 𝒄 𝟏 31 +𝒄 𝟐
T(1) = 3𝒄 𝟏 + 𝒄 𝟐
It’s easy to solve these equations for the solution 𝒄 𝟏 = 1, 𝒄 𝟐 = −1,
so the final answer is
Solving Recurrence Relations
T(n) = 𝟑 𝒏 − 1
Solving Recurrence Relations
• Non-Homogeneous Mode
Now consider what happens when the right side of equation
is not zero.
We get an equation of the form
T(n) + aT(n − 1) + bT(n − 2) = f(n)
We’ll learn how to solve in the special case that
f(n) = 𝑟 𝑛
Actually, this requires only a slight modification of the
method for the homogeneous case. This method is best
illustrated by the given example.
Solving Recurrence Relations
Example . Solve the recurrence relation
T(n) = 1 if n = 0
T(n) =3T(n − 1) + 2 𝑛 when n > 0
Solution: If the nonhomogeneous term 2 𝑛
were not
present, the characteristic equation would
be simply
x − 3 = 0.
But here,
We compare f(n) with 𝑏 𝑛.P(n)
i.e. :- f(n)= 𝑏 𝑛.P(n)
Solving Recurrence Relations
In the presence of the nonhomogeneous term, however,
we must multiply this by (𝑥 − 2)0+1
So, the characteristic equation is actually
(x − 3)(x − 2) = 0,
so the general solution is
T(n) = 𝒄 𝟏. 3 𝑛 + 𝒄 𝟐. 2 𝑛
we’ll need two equations to find the constants 𝒄 𝟏 and
𝒄 𝟐.
We can get a second value to use by simply applying the
recurrence formula
for n = 1
T(1) = 3T(0) +21
T(1) = 3(1) + 2 = 5
We now proceed as usual
1 = T(0) = c13 0 + c22 0 = c1 + c2
5 = T(1) = c13 1 + c22 1 = 3c1 + 2c2
These equations have solution c1 = 3 and c2 = −2, so the
exact solution is
Solving Recurrence Relations
T(n) = (3) 𝟑 𝒏 − (2) 𝟐 𝒏 = 𝟑 𝒏+𝟏 − 𝟐 𝒏+𝟏
Thank you….!!!!!

Weitere ähnliche Inhalte

Was ist angesagt?

Modeling with Recurrence Relations
Modeling with Recurrence RelationsModeling with Recurrence Relations
Modeling with Recurrence RelationsDevanshu Taneja
 
Sequences and Series (Mathematics)
Sequences and Series (Mathematics) Sequences and Series (Mathematics)
Sequences and Series (Mathematics) Dhrumil Maniar
 
recurrence relations
 recurrence relations recurrence relations
recurrence relationsAnurag Cheela
 
Sequences and Series
Sequences and SeriesSequences and Series
Sequences and Seriessujathavvv
 
Proofs by contraposition
Proofs by contrapositionProofs by contraposition
Proofs by contrapositionAbdur Rehman
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languagesparmeet834
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 
Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysisSoujanya V
 
Algorithm Using Divide And Conquer
Algorithm Using Divide And ConquerAlgorithm Using Divide And Conquer
Algorithm Using Divide And ConquerUrviBhalani2
 
Relations
RelationsRelations
RelationsGaditek
 
Well-Ordering Principle
Well-Ordering Principle Well-Ordering Principle
Well-Ordering Principle Yassirdino
 
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program CorrectnessCMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctnessallyn joy calcaben
 
asymptotic notations i
asymptotic notations iasymptotic notations i
asymptotic notations iAli mahmood
 
Infinite sequence and series
Infinite sequence and seriesInfinite sequence and series
Infinite sequence and seriesBhavik A Shah
 
CLOSEST PAIR (Final)
CLOSEST PAIR (Final)CLOSEST PAIR (Final)
CLOSEST PAIR (Final)Aruneel Das
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1Amrinder Arora
 

Was ist angesagt? (20)

Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Modeling with Recurrence Relations
Modeling with Recurrence RelationsModeling with Recurrence Relations
Modeling with Recurrence Relations
 
Sequences and Series (Mathematics)
Sequences and Series (Mathematics) Sequences and Series (Mathematics)
Sequences and Series (Mathematics)
 
recurrence relations
 recurrence relations recurrence relations
recurrence relations
 
Sequences and Series
Sequences and SeriesSequences and Series
Sequences and Series
 
Properties of relations
Properties of relationsProperties of relations
Properties of relations
 
Proofs by contraposition
Proofs by contrapositionProofs by contraposition
Proofs by contraposition
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysis
 
Algorithm Using Divide And Conquer
Algorithm Using Divide And ConquerAlgorithm Using Divide And Conquer
Algorithm Using Divide And Conquer
 
Relations
RelationsRelations
Relations
 
Well-Ordering Principle
Well-Ordering Principle Well-Ordering Principle
Well-Ordering Principle
 
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program CorrectnessCMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
CMSC 56 | Lecture 12: Recursive Definition & Algorithms, and Program Correctness
 
asymptotic notations i
asymptotic notations iasymptotic notations i
asymptotic notations i
 
Infinite sequence and series
Infinite sequence and seriesInfinite sequence and series
Infinite sequence and series
 
CLOSEST PAIR (Final)
CLOSEST PAIR (Final)CLOSEST PAIR (Final)
CLOSEST PAIR (Final)
 
String matching algorithm
String matching algorithmString matching algorithm
String matching algorithm
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
Maxima and minima
Maxima and minimaMaxima and minima
Maxima and minima
 

Ähnlich wie Algorithm Design and Analysis Using Recurrence Relations

Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrencesWaqas Akram
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrencesWaqas Akram
 
Recurrence equations
Recurrence equationsRecurrence equations
Recurrence equationsTarun Gehlot
 
Recurrence_Theory.pptx studdents nees free
Recurrence_Theory.pptx studdents nees freeRecurrence_Theory.pptx studdents nees free
Recurrence_Theory.pptx studdents nees freeWhite44420
 
Power Series - Legendre Polynomial - Bessel's Equation
Power Series - Legendre Polynomial - Bessel's EquationPower Series - Legendre Polynomial - Bessel's Equation
Power Series - Legendre Polynomial - Bessel's EquationArijitDhali
 
Analysis Of Algorithms Ii
Analysis Of Algorithms IiAnalysis Of Algorithms Ii
Analysis Of Algorithms IiSri Prasanna
 
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdfRishikeshJha33
 
lecture 3
lecture 3lecture 3
lecture 3sajinsc
 
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALESNONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALESTahia ZERIZER
 
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...Aladdinew
 
Week 8 [compatibility mode]
Week 8 [compatibility mode]Week 8 [compatibility mode]
Week 8 [compatibility mode]Hazrul156
 
Algorithm Design and Complexity - Course 3
Algorithm Design and Complexity - Course 3Algorithm Design and Complexity - Course 3
Algorithm Design and Complexity - Course 3Traian Rebedea
 

Ähnlich wie Algorithm Design and Analysis Using Recurrence Relations (20)

Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
 
Recurrence equations
Recurrence equationsRecurrence equations
Recurrence equations
 
Ch07 7
Ch07 7Ch07 7
Ch07 7
 
Ch07 8
Ch07 8Ch07 8
Ch07 8
 
Time complexity
Time complexityTime complexity
Time complexity
 
Recurrence_Theory.pptx studdents nees free
Recurrence_Theory.pptx studdents nees freeRecurrence_Theory.pptx studdents nees free
Recurrence_Theory.pptx studdents nees free
 
Power Series - Legendre Polynomial - Bessel's Equation
Power Series - Legendre Polynomial - Bessel's EquationPower Series - Legendre Polynomial - Bessel's Equation
Power Series - Legendre Polynomial - Bessel's Equation
 
01_AJMS_317_21.pdf
01_AJMS_317_21.pdf01_AJMS_317_21.pdf
01_AJMS_317_21.pdf
 
Analysis Of Algorithms Ii
Analysis Of Algorithms IiAnalysis Of Algorithms Ii
Analysis Of Algorithms Ii
 
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
 
lecture 3
lecture 3lecture 3
lecture 3
 
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALESNONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
 
2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...
2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...
2018 MUMS Fall Course - Statistical Representation of Model Input (EDITED) - ...
 
Linear regression
Linear regressionLinear regression
Linear regression
 
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
 
Week 8 [compatibility mode]
Week 8 [compatibility mode]Week 8 [compatibility mode]
Week 8 [compatibility mode]
 
Algorithm Design and Complexity - Course 3
Algorithm Design and Complexity - Course 3Algorithm Design and Complexity - Course 3
Algorithm Design and Complexity - Course 3
 
Ch05 2
Ch05 2Ch05 2
Ch05 2
 
Ch07 9
Ch07 9Ch07 9
Ch07 9
 

Kürzlich hochgeladen

JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Kürzlich hochgeladen (20)

JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

Algorithm Design and Analysis Using Recurrence Relations

  • 1. Department of Information Technology Subject: . Design and Analysis of Algorithm Topic:- Recurrence Relations TAE:2 Submitted by: Soumya Srinivas-03 Pratiksha Mohod-13 Samiksha Khanorkar-18 Guided by:- Prof. Kapil K. Wankhade
  • 2. Recurrence Relations A recurrence relation for a sequence { 𝑎 𝑛 } is an equation that expresses 𝑎 𝑛 in terms of one or more of the previous terms in the sequence, 𝑎0, 𝑎1, . . . , 𝑎 𝑛+1 For all integers n ≥ 𝑎0 where 𝑎0 is a nonnegative integer. A sequence is called a solution of a recurrence relation if its terms satisfy the recurrence relation.
  • 3. • Consider the example of Fibonacci numbers F(n) = F(n − 1) + F(n − 2) F(1) = 1 F(0) = 1 Recurrence Relations In the Fibonacci numbers we needed two initial conditions, F(0) =1 and F(1) = 1 since F(n) was defined by the two previous terms in the sequence. • Generally, recurrences can have the form T(n) = aT ( n/b) + f(n)
  • 4. Recurrence relations have two parts: recursive terms and non- recursive terms. Recurrence Relations T(n) = 2T(n − 2) + 𝒏 𝟐 − 10 Recursive Non-Recursive Recursive terms come from when an algorithm calls itself. Non-recursive terms correspond to the “non-recursive” cost of the algorithm work the algorithm performs within a function.
  • 5.
  • 6. Solving Recurrence Relations • Homogeneous Mode Consider the recurrence relation T(n) + aT(n − 1) + bT(n − 2) = 0 The idea for solving this relation is to “guess” a solution of the form T(n) = x n Since T(n − 1) = 𝑥 𝑛−1 and T(n − 2) = 𝑥 𝑛−2 we get the equation x n + axn−1 + bxn−2 = 0 Since x is clearly not zero, we can divide by 𝑥 𝑛−2 to get 𝑥2 + ax + b = 0
  • 7. If this equation factors as (x−𝑟1) (x−𝑟2) = 0 with 𝑟1≠ 𝑟2 (so that the characteristic equation has two distinct roots), then the general solution is T(n) = 𝒄 𝟏. 𝒓 𝟏 𝒏+ 𝒄 𝟐. 𝒓 𝟐 𝒏 Since x is clearly not zero, we can divide by 𝑥 𝑛−2 to get 𝑥2 + ax + b = 0 Solving Recurrence Relations
  • 8. Solving Recurrence Relations Example . Solve the recurrence relation T(n) − 4T(n − 1) + 3T(n − 2) = 0 T(0) = 0 T(1) = 2 Solution: The characteristic equation is 𝑥2 − 4x + 3 = 0, or (x − 3)(x − 1) = 0, so the general solution is, T(n) = 𝒄 𝟏 3 𝑛 + 𝒄 𝟐 1 𝑛 T(n) = 𝒄 𝟏 3 𝑛 + 𝒄 𝟐.
  • 9. To find 𝒄 𝟏 and 𝒄 𝟐 we plug in the initial conditions to get two equations in those two variables: 0 = T(0) = 𝒄 𝟏 30 + 𝒄 𝟐 T(0) =𝒄 𝟏+ 𝒄 𝟐 2 = T(1) = 𝒄 𝟏 31 +𝒄 𝟐 T(1) = 3𝒄 𝟏 + 𝒄 𝟐 It’s easy to solve these equations for the solution 𝒄 𝟏 = 1, 𝒄 𝟐 = −1, so the final answer is Solving Recurrence Relations T(n) = 𝟑 𝒏 − 1
  • 10. Solving Recurrence Relations • Non-Homogeneous Mode Now consider what happens when the right side of equation is not zero. We get an equation of the form T(n) + aT(n − 1) + bT(n − 2) = f(n) We’ll learn how to solve in the special case that f(n) = 𝑟 𝑛 Actually, this requires only a slight modification of the method for the homogeneous case. This method is best illustrated by the given example.
  • 11. Solving Recurrence Relations Example . Solve the recurrence relation T(n) = 1 if n = 0 T(n) =3T(n − 1) + 2 𝑛 when n > 0 Solution: If the nonhomogeneous term 2 𝑛 were not present, the characteristic equation would be simply x − 3 = 0. But here, We compare f(n) with 𝑏 𝑛.P(n) i.e. :- f(n)= 𝑏 𝑛.P(n)
  • 12. Solving Recurrence Relations In the presence of the nonhomogeneous term, however, we must multiply this by (𝑥 − 2)0+1 So, the characteristic equation is actually (x − 3)(x − 2) = 0, so the general solution is T(n) = 𝒄 𝟏. 3 𝑛 + 𝒄 𝟐. 2 𝑛 we’ll need two equations to find the constants 𝒄 𝟏 and 𝒄 𝟐.
  • 13. We can get a second value to use by simply applying the recurrence formula for n = 1 T(1) = 3T(0) +21 T(1) = 3(1) + 2 = 5 We now proceed as usual 1 = T(0) = c13 0 + c22 0 = c1 + c2 5 = T(1) = c13 1 + c22 1 = 3c1 + 2c2 These equations have solution c1 = 3 and c2 = −2, so the exact solution is Solving Recurrence Relations T(n) = (3) 𝟑 𝒏 − (2) 𝟐 𝒏 = 𝟑 𝒏+𝟏 − 𝟐 𝒏+𝟏