SlideShare a Scribd company logo
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….!!!!!

More Related Content

What's hot

RecurrenceRelations.ppt
RecurrenceRelations.pptRecurrenceRelations.ppt
RecurrenceRelations.ppt
MumitAhmed1
 
Solving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relationsSolving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relations
Dr. Maamoun Ahmed
 
Hw1 solution
Hw1 solutionHw1 solution
Hw1 solution
iqbal ahmad
 
Newton backward interpolation
Newton backward interpolationNewton backward interpolation
Newton backward interpolation
MUHAMMADUMAIR647
 
44 randomized-algorithms
44 randomized-algorithms44 randomized-algorithms
44 randomized-algorithms
AjitSaraf1
 
Linear transformations and matrices
Linear transformations and matricesLinear transformations and matrices
Linear transformations and matrices
EasyStudy3
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
Amrinder Arora
 
Mathematical induction by Animesh Sarkar
Mathematical induction by Animesh SarkarMathematical induction by Animesh Sarkar
Mathematical induction by Animesh Sarkar
Animesh Sarkar
 
Signals and systems-3
Signals and systems-3Signals and systems-3
Signals and systems-3
sarun soman
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statistics
Rajendran
 
Combinatorics
CombinatoricsCombinatorics
Combinatorics
Anjali Devi J S
 
Gamma & Beta functions
Gamma & Beta functionsGamma & Beta functions
Gamma & Beta functions
Selvaraj John
 
Generating function
Generating functionGenerating function
Unit 2 signal &system
Unit 2 signal &systemUnit 2 signal &system
Unit 2 signal &system
sushant7dare
 
Ordinary differential equations
Ordinary differential equationsOrdinary differential equations
Ordinary differential equationsAhmed Haider
 
Fourier analysis of signals and systems
Fourier analysis of signals and systemsFourier analysis of signals and systems
Fourier analysis of signals and systems
Babul Islam
 
Recurrence relation solutions
Recurrence relation solutionsRecurrence relation solutions
Recurrence relation solutions
subhashchandra197
 
Mathematical induction
Mathematical inductionMathematical induction
Mathematical inductionSman Abbasi
 
Numerical solution of ordinary differential equations GTU CVNM PPT
Numerical solution of ordinary differential equations GTU CVNM PPTNumerical solution of ordinary differential equations GTU CVNM PPT
Numerical solution of ordinary differential equations GTU CVNM PPT
Panchal Anand
 

What's hot (20)

RecurrenceRelations.ppt
RecurrenceRelations.pptRecurrenceRelations.ppt
RecurrenceRelations.ppt
 
Solving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relationsSolving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relations
 
Hw1 solution
Hw1 solutionHw1 solution
Hw1 solution
 
Newton backward interpolation
Newton backward interpolationNewton backward interpolation
Newton backward interpolation
 
44 randomized-algorithms
44 randomized-algorithms44 randomized-algorithms
44 randomized-algorithms
 
Linear transformations and matrices
Linear transformations and matricesLinear transformations and matrices
Linear transformations and matrices
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
Mathematical induction by Animesh Sarkar
Mathematical induction by Animesh SarkarMathematical induction by Animesh Sarkar
Mathematical induction by Animesh Sarkar
 
Signals and systems-3
Signals and systems-3Signals and systems-3
Signals and systems-3
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statistics
 
Combinatorics
CombinatoricsCombinatorics
Combinatorics
 
Gamma & Beta functions
Gamma & Beta functionsGamma & Beta functions
Gamma & Beta functions
 
Generating function
Generating functionGenerating function
Generating function
 
Recursion DM
Recursion DMRecursion DM
Recursion DM
 
Unit 2 signal &system
Unit 2 signal &systemUnit 2 signal &system
Unit 2 signal &system
 
Ordinary differential equations
Ordinary differential equationsOrdinary differential equations
Ordinary differential equations
 
Fourier analysis of signals and systems
Fourier analysis of signals and systemsFourier analysis of signals and systems
Fourier analysis of signals and systems
 
Recurrence relation solutions
Recurrence relation solutionsRecurrence relation solutions
Recurrence relation solutions
 
Mathematical induction
Mathematical inductionMathematical induction
Mathematical induction
 
Numerical solution of ordinary differential equations GTU CVNM PPT
Numerical solution of ordinary differential equations GTU CVNM PPTNumerical solution of ordinary differential equations GTU CVNM PPT
Numerical solution of ordinary differential equations GTU CVNM PPT
 

Similar to recurence solutions

Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
Waqas Akram
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
Waqas Akram
 
Recurrence equations
Recurrence equationsRecurrence equations
Recurrence equationsTarun Gehlot
 
Time complexity
Time complexityTime complexity
Time complexity
Kartik Chandra Mandal
 
Recurrence_Theory.pptx studdents nees free
Recurrence_Theory.pptx studdents nees freeRecurrence_Theory.pptx studdents nees free
Recurrence_Theory.pptx studdents nees free
White44420
 
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
ArijitDhali
 
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.pdf
RishikeshJha33
 
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 SCALES
Tahia ZERIZER
 
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) - ...
The Statistical and Applied Mathematical Sciences Institute
 
Linear regression
Linear regressionLinear regression
Linear regression
Zoya Bylinskii
 
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
 

Similar to recurence solutions (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
 

Recently uploaded

Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 

Recently uploaded (20)

Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 

recurence solutions

  • 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) 𝟐 𝒏 = 𝟑 𝒏+𝟏 − 𝟐 𝒏+𝟏