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.
recurence solutions
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

PPTX
recurrence relations
PPT
Relations
PPTX
bag 3 PDLHON, METODE KOEFISIEN TAK TENTU, VARIASI PARAMETER.pptx
PPTX
Sequences and Series
PDF
Solving linear homogeneous recurrence relations
PDF
Recurrence relation
PDF
Recurrence relations
PDF
Higher Order Differential Equation
recurrence relations
Relations
bag 3 PDLHON, METODE KOEFISIEN TAK TENTU, VARIASI PARAMETER.pptx
Sequences and Series
Solving linear homogeneous recurrence relations
Recurrence relation
Recurrence relations
Higher Order Differential Equation

What's hot (20)

PPTX
Sequence and Series in Discrete Structure
PPTX
Lesson 9 transcendental functions
PPTX
CMSC 56 | Lecture 16: Equivalence of Relations & Partial Ordering
PPTX
CMSC 56 | Lecture 13: Relations and their Properties
PPTX
Relations
PPTX
Systems Of Differential Equations
PPT
Number theory
PPTX
matriks, relasi, dan fungsi
PPTX
Mathematical induction
PPTX
Chinese remainder theorem
PDF
Chapter 2: Relations
PPT
Combinatorics
PPT
MATLAB ODE
PPTX
number theory.ppt
PDF
L7 fuzzy relations
PPTX
Lagrange’s interpolation formula
PPTX
Mathematical Induction
PDF
2.5 Transformations of Functions
PDF
Analisis real-lengkap-a1c
PPT
Set theory
Sequence and Series in Discrete Structure
Lesson 9 transcendental functions
CMSC 56 | Lecture 16: Equivalence of Relations & Partial Ordering
CMSC 56 | Lecture 13: Relations and their Properties
Relations
Systems Of Differential Equations
Number theory
matriks, relasi, dan fungsi
Mathematical induction
Chinese remainder theorem
Chapter 2: Relations
Combinatorics
MATLAB ODE
number theory.ppt
L7 fuzzy relations
Lagrange’s interpolation formula
Mathematical Induction
2.5 Transformations of Functions
Analisis real-lengkap-a1c
Set theory
Ad

Similar to recurence solutions (20)

PDF
Impact of Linear Homogeneous Recurrent Relation Analysis
PDF
Solving recurrences
PDF
Solving recurrences
PPTX
Recurrence_Theory.pptx studdents nees free
PPT
the ppt on chap6 of brassard and Bratley
PDF
Daa linear recurrences
PPTX
Unit I Recurrence Relations.pptx Fundamentals
PPTX
LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
PPT
recurrence relations in analysis of algorithm
PPTX
power point DM Unit-4 part2 -21-04-2020.pptx
PPTX
Recurrence Relation
PPTX
PCC_CS_404_OUCHITYAPRODHAN_17000124029[1].pptx
DOCX
Recurrence equations
PPT
Time complexity
PDF
Chapter 4 Discrete Mathematics and Combinatorics.pdf
PPTX
PDF
Chapter_4 (Advanced counting methods) (1).pdf
PDF
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
PDF
Lecture no 9(extended master method)
PDF
CPSC 125 Ch 2 Sec 5
Impact of Linear Homogeneous Recurrent Relation Analysis
Solving recurrences
Solving recurrences
Recurrence_Theory.pptx studdents nees free
the ppt on chap6 of brassard and Bratley
Daa linear recurrences
Unit I Recurrence Relations.pptx Fundamentals
LINEAR RECURRENCE RELATIONS WITH CONSTANT COEFFICIENTS
recurrence relations in analysis of algorithm
power point DM Unit-4 part2 -21-04-2020.pptx
Recurrence Relation
PCC_CS_404_OUCHITYAPRODHAN_17000124029[1].pptx
Recurrence equations
Time complexity
Chapter 4 Discrete Mathematics and Combinatorics.pdf
Chapter_4 (Advanced counting methods) (1).pdf
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
Lecture no 9(extended master method)
CPSC 125 Ch 2 Sec 5
Ad

Recently uploaded (20)

PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
1_English_Language_Set_2.pdf probationary
PDF
advance database management system book.pdf
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
IGGE1 Understanding the Self1234567891011
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
Trump Administration's workforce development strategy
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Share_Module_2_Power_conflict_and_negotiation.pptx
1_English_Language_Set_2.pdf probationary
advance database management system book.pdf
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Weekly quiz Compilation Jan -July 25.pdf
AI-driven educational solutions for real-life interventions in the Philippine...
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
IGGE1 Understanding the Self1234567891011
B.Sc. DS Unit 2 Software Engineering.pptx
TNA_Presentation-1-Final(SAVE)) (1).pptx
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Paper A Mock Exam 9_ Attempt review.pdf.
History, Philosophy and sociology of education (1).pptx
FORM 1 BIOLOGY MIND MAPS and their schemes
Trump Administration's workforce development strategy

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