SlideShare a Scribd company logo
Addis Ababa science & Technology University
Department of Mathematics
Discrete mathematics-I
CHAPTER-3: Recurrence relation
TALK OUTLINES
3.1 Definition and Examples of recurrence relation
3.2 Modeling using recurrence relation
3.3 Solving recurrence relation
2
3
 Many counting problems cannot be solved
easily using the methods discussed in Chapter 1.
 One such problem is: How many bit strings of
length n do not contain two consecutive
zeros?
 The techniques studied in this chapter, together
with the basic techniques of Chapter 1, can
be used to solve many counting problems.
INTRODUCTION
The number of bacteria in a colony doubles every
hour. If the colony begins with 5 bacteria, how many
will be present in n hours?
Let an : the number of bacteria at the end of n hours
Then;
an = 2an-1, a0=5
What we are doing actually?
We find a formula/model for an (the relationship
between an and a0) – this is called recurrence
relations between the term of sequence.
Motivation
Solution:
Since bacteria double every hour Initial condition
By using
recursive
definition
3.1
RECURRENCE
RELATION
• A recursive algorithm provides the solution of a problem of size n in term of
the solutions of one or more instances of the same problem in smaller size.
• The initial condition specify the terms that precede the first term where
the recurrence relation takes effect.
3.1 Recurrence Relation
A recurrence relation for the sequence {an} is an equation that
expresses an in terms of one or more of the previous terms of the
sequence, namely, a0, a1,…, an-1, for all integers n with n ≥ n0, where n0
is a nonnegative integer.
A sequence is call solution of a recurrence relation if its term satisfy
the recurrence relation.
an = 2an-1
a0 = 5 Initial condition
Recurrence relation
Recursive
definition
3.1
RECURRENCE
RELATION
Let {an} be a sequence that satisfies the recurrence relation
an = an-1 – an-2 for n = 2, 3,4, and suppose that a0 =3 and a1 = 5.
List the first four term.
a0 = 3
a1 = 5
a2 = a1 – a0 = ___________________
a3 = __________________________
What is a5?
a5 = __________________________
Example 3.1
3.1
RECURRENCE
RELATION
Determine whether {an} where an = 3n for every nonnegative
integer n, is a solution of recurrence relation an = 2an-1 – an-2
for n = 2, 3, 4, …
Suppose that an = 3n for every nonnegative integer n,
Then for n ≥ 2;
2an-1 – an-2 = ___________________
Therefore,
Determine whether {an} where an = 5 for every nonnegative
integer n, is a solution of recurrence relation an = 2an-1 – an-2
for n = 2, 3, 4, …
2an-1 – an-2 = ___________________
Example 3.2
3.1
RECURRENCE
RELATION
1. Let an denotes the nth term of a sequence satisfying the
given initial condition (s) and the recurrence relation.
Compute the first four terms of the sequence.
EXERCISE 3.1
0 1
1
128, for 1
4
n n
a a a n

  
A
B
C
D
E
1 1
5, 7 2 for 2
n n
b b b n

   
 
2
1 1 1
2, 3 2 for 2
n n n
a a a a n
 
     
1 2 3 1 2 3
1, 2, 3, for 4
n n n n
d d d d d d d n
  
      
1 2 1 2
1, 2, 3 for 3
n n n
a a a a a n
 
    
3.1
RECURRENCE
RELATION
2. Is the sequence {an} a solution of the if
3. Is the sequence {an} a solution of the if
4. Show that the sequence {an} is a solution of the recurrence
relation if
EXERCISE 3.1
2 1
n
a n
 
1 2
3 2
n n n
a a a
 
  
1 2
2 2
n n n
a a a
 
   2
3
n
a n
 
 
3
n
n
a  
1 2
3 6
n n n
a a a
 
  
3.2
MODELING
WITH
RECURRENCE
• We can use recurrence relation to model a wide variety of
problems such as
– Finding a compound interest
– Counting a population of rabbits
– Determining the number of moves in the Tower of Hanoi
puzzle
– Counting bit strings
3.2 Modeling with Recurrence Relation
3.2
MODELING
WITH
RECURRENCE
Suppose that a person deposits Birr10,000 in a savings account
at CBE yielding 11% per year with interest compounded
annually. Define recursively the compound amount in the
account at the end of n years.
Let an : the amount in the account after n years
Then;
an = (compound amount at the end of (n -1)th years)
+ (interest for the nth years)
an = an-1 + 0.11an-1
= 1.11 an-1
With initial condition; a0 = 10,000
Example 3.3: Compound interest
Solution:
3.2
MODELING
WITH
RECURRENCE
A young pair of rabbits (one of each sex) is placed on an island. A pair
of rabbits does not breed until they are 2 months old. After they are 2
months old, each pair of rabbits produces another pair each month.
Find a recurrence relation for the numbers of pairs of rabbits on the
island after n months if all the rabbits alive.
Let fn : the numbers of pairs of rabbits on the island after n months
Then;
fn = (number of pairs of rabbits in (n -1)th months)
+ (number of newborn pairs of rabbits)
fn = fn-1 + fn-2
With initial condition; f1 = 1 and f2 = 1 ; n ≥ 3
Example 3.4: Population of rabbits
Solution:
WHY???
[Problem develop by Leonardo Pisano (Liber abaci, 13th century) – lead to Fibonacci number]
3.2
MODELING
WITH
RECURRENCE
Example 3.4: Population of rabbits
3.2
MODELING
WITH
RECURRENCE
• Popular Puzzle invented by Edouard Lucas
(French Mathematician, late 19th century)
RULES OF PUZZLE:
– Suppose we have 3 pegs labeled A, B, C and a set of disks of
different sizes.
– These disks are arranged from the largest disk at the bottom
to the smallest disk at the top (1 to n disks) on peg A.
– The goal: to have all disks on peg C in order of size, with the
largest on the bottom.
– Only one disk is allow to move at a time from a peg to another.
– Each peg must always be arranged from the largest at the
bottom to the smallest at the top
Example 3.5: Tower of Hanoi
3.2
MODELING
WITH
RECURRENCE
ILLUSTRATION: SOLUTION
Example 3.5: Tower of Hanoi
A B C
A B C
Initial Position in the Tower of Hanoi
Intermediate Position in the Tower of Hanoi
n disks
n-1 disks
Hn-1 moves
Let Hn :
the numbers of
moves with n disks
transfer the top of
n-1 disks to peg B
3.2
MODELING
WITH
RECURRENCE
ILLUSTRATION: SOLUTION
Example 3.5: Tower of Hanoi
A B C
A B C
Intermediate Position in the Tower of Hanoi
Last Position in the Tower of Hanoi
1 disks
n disks
Hn-1 moves
Moves the largest
disk to peg C
transfer the top of
n-1 disks to peg B
1 move
3.2
RECURRENCE
RELATION
Thus the number of moves is given by:
Where:
Example 3.5: Tower of Hanoi
Solution (continue):
1 1
2 1 ; 1
n n
H H H

  
Hn-1 moves
Moves the largest
disk to peg C
transfer the top of
n-1 disks to peg C
1 move
Hn-1 moves
transfer the top of
n-1 disks to peg B
+ +
3.2
MODELING
WITH
RECURRENCE
Find a recurrence relation and give initial conditions for the number of
bit strings of length n that do not have two consecutive 0s. How many
bit strings are there of six length?
Let an : number of bit strings of length n that do not have two
consecutive 0s
Then;
an = (number of bit strings of length n-1 that do not have
two consecutive 0s)
+ (number of bit strings of length n-2 that do not have
two consecutive 0s)
an = an-1 + an-2 ; n ≥ 3
With initial condition;
a1 = 2, both strings of length 1 do not have consecutive 0s ( 0 and 1)
a2 = 3, the valid strings only 01, 10 and 11
Example 3.6: Bit Strings
Solution:
Solve yourself
3.2
MODELING
WITH
RECURRENCE
A computer system considers a string of decimal digits a valid codeword if it
contains an even number of 0 digits. For instance, 1230407869 is valid,
whereas 120987045608 is not valid. Let an be the number of valid n-digit
codewords. Find a recurrence relation for an.
Let an : the number of valid n-digit codewords
Then;
an = (number of valid n-digit codewords obtained by adding a
digit other than 0 at the end of a valid string of length n – 1)
+ (number of valid n-digit codewords obtained by adding a
digit 0 at the end of an invalid string of length n – 1)
With initial condition;
a1 = 9, there are 10 one-digit strings and only one the string 0 not valid
Example 3.7: Codeword enumeration
Solution:
 
1 1
1 1 1
9 10 8 10
n n
n n n n
a a a a
 
  
    
3.2
MODELING
WITH
RECURRENCE
A valid codeword of length n can be formed by:
A) Adding a digit other than 0 at the end of a valid string of length n – 1
- This can be done in nine ways. Hence, a valid string with n digits can
be formed in this manner in ways.
B) Adding a digit 0 at the end of an invalid string of length n – 1
- This produces a string with an even number of 0 digits because the
invalid string of length n – 1 has an odd number of 0 digits. The number
of ways that this can be done equals the number of invalid (n – 1)-digit
strings. Because there are strings of length n – 1, and are
valid, then there are invalid (n – 1)-digit strings.
Thus;
Example 3.7: Codeword enumeration
 
1 1
1 1 1 1
9 10 8 10 , 9, 2
n n
n n n n
a A B a a a a n
 
  
        
1
9 n
a 
1
10n
1
n
a 
1
1
10n
n
a



3.2
MODELING
WITH
RECURRENCE
6. Define recursively : 1, 4, 7, 10, 13, …
7. Beti deposits BIRR 1500 in a local savings bank at an
annual interest rate of 8% compounded annually. Define
recursively the compound amount an she will have in her
account at the end of n years. How much will be in her
account after 3 years?
8. There are n students at a class. Each person shakes
hands with everybody else exactly one. Define
recursively the number of handshakes that occur.
EXERCISE 3.1
3.2
MODELING
WITH
RECURRENCE
9. Find a recurrence relation and initial condition for the
number of ways to climb n stairs if the person climbing the
stairs can take one, two or three stairs at a time. How
many ways can this person climb a building with eight
stairs?
10. Find a recurrence relation and initial condition for the
number of bit strings of length n that contain three
consecutive 0s. How many bit strings of length seven
contain three consecutive 0s?
11. Find a recurrence relation for the number of bit sequences
of length n with an even number of 0s?
EXERCISE 3.1
3.3 SOLVING RECURRENCE RELATION
• Solve a recurrence relation using iterative
method
• Solve a linear homogeneous recurrence
relation with constant coefficients
• Solve a linear nonhomogeneous recurrence
relation with constant coefficients
• Solving the recurrence relation for a function f means
finding an explicit formula for f (n). The iterative
method of solving it involves two steps:
– Apply the recurrence formula iteratively and look
for the pattern to predict an explicit formula
 Forward: start from a0 to an
 Backward : start from an to a0
– Use Induction to prove that the formula does
indeed hold for every possible value of the integer
n.
Iterative Method
3.3
SOLVING
RECURRENCE
RELATION
Using the iterative method, predict a solution for the following
recurrence relation with the given initial condition.
Example 3.3.1 (a): Iterative Method
 
 
 
0
1 0
2
2 1 0 0
2 3
3 2 0 0
1
1 0 0
1
2
2 2 2 2
2 2 2 2
2 2 2 2 2 ; 1
n n n
n n
S
S S
S S S S
S S S S
S S S S n




  
  
    
Solution: (FORWARD)
1 0
2 ; 1
n n
S S S

 
Solution: (BACKWARD)
1
2
2
3
3
0
2
2
2
2 2
n n
n
n
n n
S S
S
S
S






 
3.3
SOLVING
RECURRENCE
RELATION
Suppose that a person deposits Birr10,000 in a savings account
at a CBE yielding 11% per year with interest compounded
annually. How much will be in the account after 30 years?
Let an : the amount in the account after n years
Then;
an = (compound amount at the end of (n -1)th years)
+ (interest for the nth years)
an = an-1 + 0.11an-1
= 1.11 an-1 , n ≥ 1
With initial condition; a0 = 10,000
Example 3.3.2: Compound interest
Solution:
By iterative approach:
Thus, after 30 years the amount in the account will be:
=Birr 228,923
 
   
   
       
0
1 0
2
2 1 0
3
3 2 0
1 0
10000
1.11
1.11 1.11
1.11 1.11
1.11 1.11 1.11 10000
n n
n n
a
a a
a a a
a a a
a a a



 
 
  
Example 3.3.2: Compound interest
Solution (continue):
   
30
30 1.11 10000 ___________
a  
PROVE BY
INDUCTION !
The number of moves is given by:
By iterative approach:
 
 
1
2
2 2
2 3 2
3 3
1 2 3
1
1 2 3
2 1
2 2 1 1 2 2 1
2 2 1 2 1 2 2 2 1
2 2 2 2 1
2 2 2 2 1
2 1
n n
n n
n n
n n n
n n n
n
H H
H H
H H
H

 
 
  
  
 
     
       
     
     
 
Example 3.3: Tower of Hanoi
1 1
2 1 ; 1
n n
H H H

  
PROVE BY
INDUCTION !
3.3
SOLVING
RECURRENCE
RELATION
1. Using iterative method, predict a solution to each of the
following recurrence relation. Verify the solutions using
induction
•
•
2. There are n students at a class. Each person shakes hands
with everybody else exactly one. Define recursively the
number of handshakes that occur. Solve this recurrence
relation using iterative method and prove it using induction.
3. If a deposit of birr 100 is made on the first day of each
month into an account that pays 6% interest per year
compounded monthly, show that the amount in the account
after 18 years is birr 38929.
1 0
4 ; 0 ; 1
n n
a a n a n

   
EXERCISE 3.3.1
2
1 1
; 1 ; 2
n n
b b n a n

   
3.3
SOLVING
RECURRENCE
RELATION
A linear homogeneous recurrence relation of degree k with
constant coefficients is a recurrence relation of the form
an = c1an-1 + c2an-2 + … + ckan-k
Where c1, c2,…, ck are real numbers and ck ≠ 0
Linear Homogeneous Recurrence
Relations with constant coefficients
Linear : The RHS is the sum of previous terms of the sequence each
multiplied by a function of n.
Homogeneous : No terms occur that are not multiplies of the aj s.
Degree k : an is expressed in terms of the previous k terms of the sequence
Constant coefficients : c1, c2,…, ck
Recurrence relation : with k initial condition
a0 = C0, a1 = C1, … ak-1= Ck-1
3.3
SOLVING
RECURRENCE
RELATION
Linear Homogeneous Recurrence Relation
Pn = (1.11) Pn-1 degree one
fn = fn-1 + fn-2 degree two
an = an-5 degree five
Not Linear Homogeneous Recurrence Relation
Hn = 2Hn-1 + 1
Bn = nBn-1
an = an-1 + a²n-2
Example 3.3.4: Linear Homogeneous RR
1. Often occur
in modeling of
problems
2. Can be
systematically
solved
3.3
SOLVING
RECURRENCE
RELATION
• OUR AIM – look for the solutions of the form , where r
is constant.
• Note that, is a solution of the recurrence relation
an = c1an-1 + c2an-2 + … + ckan-k iff .
• When both sides of this equation are divided by and
the RHS is subtracted from the left, we obtain a characteristic
equation:
• The solution of this equation are called the characteristics
roots.
Solving Linear Homogeneous Recurrence
Relations with constant coefficients
n
n
a r

n
n
a r

1 2
1 2
n n n n k
k
r c r c r c r
  
   
1 2
1 2 1 0
k k k
k k
r c r c r c r c
 

     
n k
r 
3.3
SOLVING
RECURRENCE
RELATION
Let c1, c2, …, ck be real numbers. Suppose that the
characteristics equation
has k distinct roots r1, r2, …, rk.
Then a sequence {an} is a solution of the recurrence relation
an = c1an-1 + c2an-2 + … + ckan-k iff for
n ≥ 0 and α1, α2, …, αk constant.
If the characteristic equation has several (m) repeated roots,
then the solution of the recurrence relation is given by:
Solving Linear Homogeneous Recurrence
Relations with constant coefficients
1 1 2 2
n n n
n k k
a r r r
  
   
1 2
1 2 1 0
k k k
k k
r c r c r c r c
 

     
1 1 2 1 1
n n m n n
n m k k
a r nr n r r
   
     
3.3
SOLVING
RECURRENCE
RELATION
Solve the recurrence relation an = 5an-1 - 6an-2 where a0 = 4 and
a1 = 7.
1) Find the general solution of the recurrence relation
• the characteristic equation is given by
• the characteristic roots are 2 and 3
• thus, the general solution is
2) Find the constant values, A,B and C using the initial
conditions
• Solving the linear system: : A = 5, B = -1
3) Thus the solution to the recurrence relation and initial
conditions is .
Example 3.3.5: Second-Order LHRRWCCs
Solution:
5 2 3 , 0
n n
n
a n
   
2 3
n n
n
a A B
   
2
5 6 0
r r
  
0
1
4
2 3 7
a A B
a A B
  
  
3.3
SOLVING
RECURRENCE
RELATION
Solve the recurrence relation an = 6an-1 - 11an-2 + 6an-3 where
a0 = 2, a1 =5, and a2 = 15.
1) Find the general solution of the recurrence relation
• the characteristic equation is given by
• the characteristic roots are 1, 2 and 3
• thus, the general solution is
2) Find the constant values, A and B using the initial conditions
• Solving the linear system: (A = 1, B = -1, C = 2)
3) Thus the unique solution to the recurrence relation and
initial conditions is .
Example 3.3.6: Higher-Order LHRRWCCs
Solution:
1 2 2 3 , 0
n n
n
a n
    
1 2 3
n n n
n
a A B C
     
3 2
6 11 6 0
r r r
   
0 1 2
2, 2 3 5, 4 9 15
a A B C a A B C a A B C
           
3.3
SOLVING
RECURRENCE
RELATION
Suppose that the roots of the characteristic equation of a
linear homogenous recurrence relation are 2, 2, 2, 5, 5, and
9. What is the form of general solution?
Thus the general solution to the recurrence relation is
Example 3.3.7: LHRRWCCs with multiple roots
Solution:
   
2
2
2 2 2 5 5 9
2 5 9
n n n n n n
n
n n n
a A Bn Cn D En F
A Bn Cn D En F
      
      
3.3
SOLVING
RECURRENCE
RELATION
1. What is the solution of the following recurrence relation
•
•
•
2. Find an explicit formula for Fibonacci numbers.
EXERCISE 3.3.2
1 2 0 1
2 ; 2, 7
n n n
a a a a a
 
   
1 2 0 1
6 9 ; 1, 3
n n n
a a a a a
 
   
1 2 3 0 1 2
3 3 ; 1, 2, 1
n n n n
a a a a a a a
  
        
1 2 1 2
; 1, 1
n n n
F F F F F
 
   
3.3
SOLVING
RECURRENCE
RELATION
• A Linear Nonhomogenous recurrence relation with constant
coefficients (LNHRRWCCs), that is a recurrence relation of the
form an = c1an-1 + c2an-2 + … + ckan-k + F (n) .
• Where
– c1, c2, …, ck are real numbers
– F (n) is a function not identically zero depending only n
– c1an-1 + c2an-2 + … + ckan-k is called the associated
homogenous recurrence relation
• Example:
Linear NonHomogenous Recurrence
Relations with constant coefficients
2
1 2 1
n n n
a a a n n
 
     1
2 3n
n n
a a n

 
1
3 2
n n
a a n

 
3.3
SOLVING
RECURRENCE
RELATION
Let
be the general solution of c1an-1 + c2an-2 + … + ckan-k
And
be the particular solution of LNHRRWCCs,
an = c1an-1 + c2an-2 + … + ckan-k + F (n)
Then the general solution of LNHRRWCCs is given by
There is no general method to find the particular solution.
Solving Linear NonHomogenous Recurrence
Relations with constant coefficients
 
p
n
a
 
h
n
a
   
h p
n n n
a a a
 
3.3
SOLVING
RECURRENCE
RELATION
Suppose that {an} satisfy the linear nonhomogenous recurrence relation
And
(i)When s is not a root of the characteristic equation, there is a
particular solution of the form
(ii) When s is a root of the characteristic equation , there is a
particular solution of the form
THEOREM
1 1 1 2,...,
... ( ) where ,
n n k n k k
a c a c a F n c c c
 
    
1
1 1 0 0 1
( ) ( ... ) where , ,..., ,
t t n
t t t
F n b n b n b n b s b b b s


    
1
1 1 0
( ... )
t t n
t t
p n p n p n p s


  
1
1 1 0
( ... )
m t t n
t t
n p n p n p n p s


  
3.3
SOLVING
RECURRENCE
RELATION
Find all the solutions of recurrence relation an = 3an-1 + 2n
1) Find the general solution of the associated linear homogenous
(ALH) equation.
• the ALH equation is given by an = 3an-1
• thus, the general solution is
2) Find the particular solution
• Since F(n) = 2n is polynomial with degree 1, then the trial
solution linear function: pn = cn + d (c and d are constant)
• The equation an = 3an-1 + 2n then become
• Solve for c and d will gives c = -1 and d = -3/2
• Thus, the particular solution is
3) Thus the unique solution to the recurrence relation is
Example 3.3.8: LNHRRWCCs
Solution:
 
3
h n
n
a A
 
3
3
2
n
n
a A n
   
 
 
3 1 2 0
cn d c n d n
     
  3
2
p
n
a n
  
3.3
SOLVING
RECURRENCE
RELATION
1. What is the solution of the following recurrence relation
•
•
2. What form does a particular solution of linear
nonhomogeneous recurrence relation
when
EXERCISE 3.3.3
2
1 2 0 1
5 6 8 ; 4, 7
n n n
a a a n a a
 
    
1 2 0 1
5 6 7 ; 4, 7
n
n n n
a a a a a
 
    
 
1 2
6 9
n n n
a a a F n
 
  
     
       
2
2
3 , 3 , 2
4 1 3 , 1 3
n n n
n n
F n F n n F n n
F n n F n n
  
   

More Related Content

Similar to Ch-3 lecture.pdf

Arithmetic Progression & Geometric ProgresionP
Arithmetic Progression & Geometric ProgresionPArithmetic Progression & Geometric ProgresionP
Arithmetic Progression & Geometric ProgresionP
ibha1234
 
Arithmetic And Geometric Progressions
Arithmetic And Geometric ProgressionsArithmetic And Geometric Progressions
Arithmetic And Geometric Progressions
Finni Rice
 
Ap gp
Ap gpAp gp
Ap gp
sujoy7
 
Permutations and Combinations IIT JEE+Olympiad Lecture 4
Permutations and Combinations IIT JEE+Olympiad Lecture 4Permutations and Combinations IIT JEE+Olympiad Lecture 4
Permutations and Combinations IIT JEE+Olympiad Lecture 4
Parth Nandedkar
 
Nbhm m. a. and m.sc. scholarship test 2005
Nbhm m. a. and m.sc. scholarship test 2005Nbhm m. a. and m.sc. scholarship test 2005
Nbhm m. a. and m.sc. scholarship test 2005
MD Kutubuddin Sardar
 
Generating Patterns and arithmetic sequence.pptx
Generating Patterns and arithmetic sequence.pptxGenerating Patterns and arithmetic sequence.pptx
Generating Patterns and arithmetic sequence.pptx
RenoLope1
 
2.3 Nth Term
2.3 Nth Term2.3 Nth Term
2.3 Nth Termjdrambo
 
Arithmetic sequences and series
Arithmetic sequences and seriesArithmetic sequences and series
Arithmetic sequences and series
Rose Mary Tania Arini
 
REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​
REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​
REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​
Reema
 
11.1 Sequences and Series
11.1 Sequences and Series11.1 Sequences and Series
11.1 Sequences and Series
smiller5
 
Sequence formulas direct and recursive
Sequence formulas direct and recursiveSequence formulas direct and recursive
Sequence formulas direct and recursive
Zohaib Khalid
 
Binomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relationsBinomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relations
Aqeel Rafique
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
Programming Homework Help
 
Chapter 3 - Problem Solving.pdf
Chapter 3 - Problem Solving.pdfChapter 3 - Problem Solving.pdf
Chapter 3 - Problem Solving.pdf
MinaSaflor
 
akaleshchinese.pptx
akaleshchinese.pptxakaleshchinese.pptx
akaleshchinese.pptx
SwatiSudeepta287
 
published research papers
published research paperspublished research papers
published research papers
graphicdesigner79
 
journal of mathematics research
journal of mathematics researchjournal of mathematics research
journal of mathematics research
rikaseorika
 
research paper publication journals
research paper publication journalsresearch paper publication journals
research paper publication journals
rikaseorika
 
Solutions modern particlephysics
Solutions modern particlephysicsSolutions modern particlephysics
Solutions modern particlephysics
itachikaleido
 

Similar to Ch-3 lecture.pdf (20)

Arithmetic Progression & Geometric ProgresionP
Arithmetic Progression & Geometric ProgresionPArithmetic Progression & Geometric ProgresionP
Arithmetic Progression & Geometric ProgresionP
 
Arithmetic And Geometric Progressions
Arithmetic And Geometric ProgressionsArithmetic And Geometric Progressions
Arithmetic And Geometric Progressions
 
Ap gp
Ap gpAp gp
Ap gp
 
Permutations and Combinations IIT JEE+Olympiad Lecture 4
Permutations and Combinations IIT JEE+Olympiad Lecture 4Permutations and Combinations IIT JEE+Olympiad Lecture 4
Permutations and Combinations IIT JEE+Olympiad Lecture 4
 
Nbhm m. a. and m.sc. scholarship test 2005
Nbhm m. a. and m.sc. scholarship test 2005Nbhm m. a. and m.sc. scholarship test 2005
Nbhm m. a. and m.sc. scholarship test 2005
 
Generating Patterns and arithmetic sequence.pptx
Generating Patterns and arithmetic sequence.pptxGenerating Patterns and arithmetic sequence.pptx
Generating Patterns and arithmetic sequence.pptx
 
2.3 Nth Term
2.3 Nth Term2.3 Nth Term
2.3 Nth Term
 
Arithmetic sequences and series
Arithmetic sequences and seriesArithmetic sequences and series
Arithmetic sequences and series
 
REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​
REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​
REAL AND COMPLEX NUMBERS​ And INDICES, SURD & LOGARITHM​
 
Mit6 006 f11_quiz1
Mit6 006 f11_quiz1Mit6 006 f11_quiz1
Mit6 006 f11_quiz1
 
11.1 Sequences and Series
11.1 Sequences and Series11.1 Sequences and Series
11.1 Sequences and Series
 
Sequence formulas direct and recursive
Sequence formulas direct and recursiveSequence formulas direct and recursive
Sequence formulas direct and recursive
 
Binomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relationsBinomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relations
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
Chapter 3 - Problem Solving.pdf
Chapter 3 - Problem Solving.pdfChapter 3 - Problem Solving.pdf
Chapter 3 - Problem Solving.pdf
 
akaleshchinese.pptx
akaleshchinese.pptxakaleshchinese.pptx
akaleshchinese.pptx
 
published research papers
published research paperspublished research papers
published research papers
 
journal of mathematics research
journal of mathematics researchjournal of mathematics research
journal of mathematics research
 
research paper publication journals
research paper publication journalsresearch paper publication journals
research paper publication journals
 
Solutions modern particlephysics
Solutions modern particlephysicsSolutions modern particlephysics
Solutions modern particlephysics
 

More from TamiratDejene1

Chapter 2.pptx
Chapter 2.pptxChapter 2.pptx
Chapter 2.pptx
TamiratDejene1
 
Wireless LANs.ppt
Wireless LANs.pptWireless LANs.ppt
Wireless LANs.ppt
TamiratDejene1
 
Data Link Control.ppt
Data Link Control.pptData Link Control.ppt
Data Link Control.ppt
TamiratDejene1
 
Congestion Control and QOS.ppt
Congestion Control and QOS.pptCongestion Control and QOS.ppt
Congestion Control and QOS.ppt
TamiratDejene1
 
Analog Transmission.ppt
Analog Transmission.pptAnalog Transmission.ppt
Analog Transmission.ppt
TamiratDejene1
 
Chapter 5 (Part I) - Pointers.pdf
Chapter 5 (Part I) - Pointers.pdfChapter 5 (Part I) - Pointers.pdf
Chapter 5 (Part I) - Pointers.pdf
TamiratDejene1
 
Chapter 7 (Part I) - User Defined Datatypes.pdf
Chapter 7 (Part I) - User Defined Datatypes.pdfChapter 7 (Part I) - User Defined Datatypes.pdf
Chapter 7 (Part I) - User Defined Datatypes.pdf
TamiratDejene1
 
00-intro-to-classes.pdf
00-intro-to-classes.pdf00-intro-to-classes.pdf
00-intro-to-classes.pdf
TamiratDejene1
 
DLD Chapter-5.pdf
DLD Chapter-5.pdfDLD Chapter-5.pdf
DLD Chapter-5.pdf
TamiratDejene1
 
DLD Chapter-4.pdf
DLD Chapter-4.pdfDLD Chapter-4.pdf
DLD Chapter-4.pdf
TamiratDejene1
 
DLD Chapter-2.pdf
DLD Chapter-2.pdfDLD Chapter-2.pdf
DLD Chapter-2.pdf
TamiratDejene1
 
DLD Chapter-1.pdf
DLD Chapter-1.pdfDLD Chapter-1.pdf
DLD Chapter-1.pdf
TamiratDejene1
 
DLD_Chapter_1.pdf
DLD_Chapter_1.pdfDLD_Chapter_1.pdf
DLD_Chapter_1.pdf
TamiratDejene1
 
Chapter 8_Shift Registers (EEEg4302)1.pdf
Chapter 8_Shift Registers (EEEg4302)1.pdfChapter 8_Shift Registers (EEEg4302)1.pdf
Chapter 8_Shift Registers (EEEg4302)1.pdf
TamiratDejene1
 
Chapter 7_Counters (EEEg4302).pdf
Chapter 7_Counters (EEEg4302).pdfChapter 7_Counters (EEEg4302).pdf
Chapter 7_Counters (EEEg4302).pdf
TamiratDejene1
 
Chapter 5_combinational logic (EEEg4302).pdf
Chapter 5_combinational logic (EEEg4302).pdfChapter 5_combinational logic (EEEg4302).pdf
Chapter 5_combinational logic (EEEg4302).pdf
TamiratDejene1
 
Chapter 3_Logic Gates (EEEg4302).pdf
Chapter 3_Logic Gates (EEEg4302).pdfChapter 3_Logic Gates (EEEg4302).pdf
Chapter 3_Logic Gates (EEEg4302).pdf
TamiratDejene1
 
Chapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfChapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdf
TamiratDejene1
 
Chapter 1_Introduction to digital design (EEEg4302).pdf
Chapter 1_Introduction to digital design (EEEg4302).pdfChapter 1_Introduction to digital design (EEEg4302).pdf
Chapter 1_Introduction to digital design (EEEg4302).pdf
TamiratDejene1
 
Chapter – 1 Intro to DBS.pdf
Chapter – 1 Intro to DBS.pdfChapter – 1 Intro to DBS.pdf
Chapter – 1 Intro to DBS.pdf
TamiratDejene1
 

More from TamiratDejene1 (20)

Chapter 2.pptx
Chapter 2.pptxChapter 2.pptx
Chapter 2.pptx
 
Wireless LANs.ppt
Wireless LANs.pptWireless LANs.ppt
Wireless LANs.ppt
 
Data Link Control.ppt
Data Link Control.pptData Link Control.ppt
Data Link Control.ppt
 
Congestion Control and QOS.ppt
Congestion Control and QOS.pptCongestion Control and QOS.ppt
Congestion Control and QOS.ppt
 
Analog Transmission.ppt
Analog Transmission.pptAnalog Transmission.ppt
Analog Transmission.ppt
 
Chapter 5 (Part I) - Pointers.pdf
Chapter 5 (Part I) - Pointers.pdfChapter 5 (Part I) - Pointers.pdf
Chapter 5 (Part I) - Pointers.pdf
 
Chapter 7 (Part I) - User Defined Datatypes.pdf
Chapter 7 (Part I) - User Defined Datatypes.pdfChapter 7 (Part I) - User Defined Datatypes.pdf
Chapter 7 (Part I) - User Defined Datatypes.pdf
 
00-intro-to-classes.pdf
00-intro-to-classes.pdf00-intro-to-classes.pdf
00-intro-to-classes.pdf
 
DLD Chapter-5.pdf
DLD Chapter-5.pdfDLD Chapter-5.pdf
DLD Chapter-5.pdf
 
DLD Chapter-4.pdf
DLD Chapter-4.pdfDLD Chapter-4.pdf
DLD Chapter-4.pdf
 
DLD Chapter-2.pdf
DLD Chapter-2.pdfDLD Chapter-2.pdf
DLD Chapter-2.pdf
 
DLD Chapter-1.pdf
DLD Chapter-1.pdfDLD Chapter-1.pdf
DLD Chapter-1.pdf
 
DLD_Chapter_1.pdf
DLD_Chapter_1.pdfDLD_Chapter_1.pdf
DLD_Chapter_1.pdf
 
Chapter 8_Shift Registers (EEEg4302)1.pdf
Chapter 8_Shift Registers (EEEg4302)1.pdfChapter 8_Shift Registers (EEEg4302)1.pdf
Chapter 8_Shift Registers (EEEg4302)1.pdf
 
Chapter 7_Counters (EEEg4302).pdf
Chapter 7_Counters (EEEg4302).pdfChapter 7_Counters (EEEg4302).pdf
Chapter 7_Counters (EEEg4302).pdf
 
Chapter 5_combinational logic (EEEg4302).pdf
Chapter 5_combinational logic (EEEg4302).pdfChapter 5_combinational logic (EEEg4302).pdf
Chapter 5_combinational logic (EEEg4302).pdf
 
Chapter 3_Logic Gates (EEEg4302).pdf
Chapter 3_Logic Gates (EEEg4302).pdfChapter 3_Logic Gates (EEEg4302).pdf
Chapter 3_Logic Gates (EEEg4302).pdf
 
Chapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfChapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdf
 
Chapter 1_Introduction to digital design (EEEg4302).pdf
Chapter 1_Introduction to digital design (EEEg4302).pdfChapter 1_Introduction to digital design (EEEg4302).pdf
Chapter 1_Introduction to digital design (EEEg4302).pdf
 
Chapter – 1 Intro to DBS.pdf
Chapter – 1 Intro to DBS.pdfChapter – 1 Intro to DBS.pdf
Chapter – 1 Intro to DBS.pdf
 

Recently uploaded

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
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
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
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
 
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
 
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
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
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
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
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
 
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
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 

Recently uploaded (20)

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
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
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.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 ...
 
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
 
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
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
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
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
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
 
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
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 

Ch-3 lecture.pdf

  • 1. Addis Ababa science & Technology University Department of Mathematics Discrete mathematics-I CHAPTER-3: Recurrence relation
  • 2. TALK OUTLINES 3.1 Definition and Examples of recurrence relation 3.2 Modeling using recurrence relation 3.3 Solving recurrence relation 2
  • 3. 3  Many counting problems cannot be solved easily using the methods discussed in Chapter 1.  One such problem is: How many bit strings of length n do not contain two consecutive zeros?  The techniques studied in this chapter, together with the basic techniques of Chapter 1, can be used to solve many counting problems. INTRODUCTION
  • 4. The number of bacteria in a colony doubles every hour. If the colony begins with 5 bacteria, how many will be present in n hours? Let an : the number of bacteria at the end of n hours Then; an = 2an-1, a0=5 What we are doing actually? We find a formula/model for an (the relationship between an and a0) – this is called recurrence relations between the term of sequence. Motivation Solution: Since bacteria double every hour Initial condition By using recursive definition
  • 5. 3.1 RECURRENCE RELATION • A recursive algorithm provides the solution of a problem of size n in term of the solutions of one or more instances of the same problem in smaller size. • The initial condition specify the terms that precede the first term where the recurrence relation takes effect. 3.1 Recurrence Relation A recurrence relation for the sequence {an} is an equation that expresses an in terms of one or more of the previous terms of the sequence, namely, a0, a1,…, an-1, for all integers n with n ≥ n0, where n0 is a nonnegative integer. A sequence is call solution of a recurrence relation if its term satisfy the recurrence relation. an = 2an-1 a0 = 5 Initial condition Recurrence relation Recursive definition
  • 6. 3.1 RECURRENCE RELATION Let {an} be a sequence that satisfies the recurrence relation an = an-1 – an-2 for n = 2, 3,4, and suppose that a0 =3 and a1 = 5. List the first four term. a0 = 3 a1 = 5 a2 = a1 – a0 = ___________________ a3 = __________________________ What is a5? a5 = __________________________ Example 3.1
  • 7. 3.1 RECURRENCE RELATION Determine whether {an} where an = 3n for every nonnegative integer n, is a solution of recurrence relation an = 2an-1 – an-2 for n = 2, 3, 4, … Suppose that an = 3n for every nonnegative integer n, Then for n ≥ 2; 2an-1 – an-2 = ___________________ Therefore, Determine whether {an} where an = 5 for every nonnegative integer n, is a solution of recurrence relation an = 2an-1 – an-2 for n = 2, 3, 4, … 2an-1 – an-2 = ___________________ Example 3.2
  • 8. 3.1 RECURRENCE RELATION 1. Let an denotes the nth term of a sequence satisfying the given initial condition (s) and the recurrence relation. Compute the first four terms of the sequence. EXERCISE 3.1 0 1 1 128, for 1 4 n n a a a n     A B C D E 1 1 5, 7 2 for 2 n n b b b n        2 1 1 1 2, 3 2 for 2 n n n a a a a n         1 2 3 1 2 3 1, 2, 3, for 4 n n n n d d d d d d d n           1 2 1 2 1, 2, 3 for 3 n n n a a a a a n       
  • 9. 3.1 RECURRENCE RELATION 2. Is the sequence {an} a solution of the if 3. Is the sequence {an} a solution of the if 4. Show that the sequence {an} is a solution of the recurrence relation if EXERCISE 3.1 2 1 n a n   1 2 3 2 n n n a a a      1 2 2 2 n n n a a a      2 3 n a n     3 n n a   1 2 3 6 n n n a a a     
  • 10. 3.2 MODELING WITH RECURRENCE • We can use recurrence relation to model a wide variety of problems such as – Finding a compound interest – Counting a population of rabbits – Determining the number of moves in the Tower of Hanoi puzzle – Counting bit strings 3.2 Modeling with Recurrence Relation
  • 11. 3.2 MODELING WITH RECURRENCE Suppose that a person deposits Birr10,000 in a savings account at CBE yielding 11% per year with interest compounded annually. Define recursively the compound amount in the account at the end of n years. Let an : the amount in the account after n years Then; an = (compound amount at the end of (n -1)th years) + (interest for the nth years) an = an-1 + 0.11an-1 = 1.11 an-1 With initial condition; a0 = 10,000 Example 3.3: Compound interest Solution:
  • 12. 3.2 MODELING WITH RECURRENCE A young pair of rabbits (one of each sex) is placed on an island. A pair of rabbits does not breed until they are 2 months old. After they are 2 months old, each pair of rabbits produces another pair each month. Find a recurrence relation for the numbers of pairs of rabbits on the island after n months if all the rabbits alive. Let fn : the numbers of pairs of rabbits on the island after n months Then; fn = (number of pairs of rabbits in (n -1)th months) + (number of newborn pairs of rabbits) fn = fn-1 + fn-2 With initial condition; f1 = 1 and f2 = 1 ; n ≥ 3 Example 3.4: Population of rabbits Solution: WHY??? [Problem develop by Leonardo Pisano (Liber abaci, 13th century) – lead to Fibonacci number]
  • 14. 3.2 MODELING WITH RECURRENCE • Popular Puzzle invented by Edouard Lucas (French Mathematician, late 19th century) RULES OF PUZZLE: – Suppose we have 3 pegs labeled A, B, C and a set of disks of different sizes. – These disks are arranged from the largest disk at the bottom to the smallest disk at the top (1 to n disks) on peg A. – The goal: to have all disks on peg C in order of size, with the largest on the bottom. – Only one disk is allow to move at a time from a peg to another. – Each peg must always be arranged from the largest at the bottom to the smallest at the top Example 3.5: Tower of Hanoi
  • 15. 3.2 MODELING WITH RECURRENCE ILLUSTRATION: SOLUTION Example 3.5: Tower of Hanoi A B C A B C Initial Position in the Tower of Hanoi Intermediate Position in the Tower of Hanoi n disks n-1 disks Hn-1 moves Let Hn : the numbers of moves with n disks transfer the top of n-1 disks to peg B
  • 16. 3.2 MODELING WITH RECURRENCE ILLUSTRATION: SOLUTION Example 3.5: Tower of Hanoi A B C A B C Intermediate Position in the Tower of Hanoi Last Position in the Tower of Hanoi 1 disks n disks Hn-1 moves Moves the largest disk to peg C transfer the top of n-1 disks to peg B 1 move
  • 17. 3.2 RECURRENCE RELATION Thus the number of moves is given by: Where: Example 3.5: Tower of Hanoi Solution (continue): 1 1 2 1 ; 1 n n H H H     Hn-1 moves Moves the largest disk to peg C transfer the top of n-1 disks to peg C 1 move Hn-1 moves transfer the top of n-1 disks to peg B + +
  • 18. 3.2 MODELING WITH RECURRENCE Find a recurrence relation and give initial conditions for the number of bit strings of length n that do not have two consecutive 0s. How many bit strings are there of six length? Let an : number of bit strings of length n that do not have two consecutive 0s Then; an = (number of bit strings of length n-1 that do not have two consecutive 0s) + (number of bit strings of length n-2 that do not have two consecutive 0s) an = an-1 + an-2 ; n ≥ 3 With initial condition; a1 = 2, both strings of length 1 do not have consecutive 0s ( 0 and 1) a2 = 3, the valid strings only 01, 10 and 11 Example 3.6: Bit Strings Solution: Solve yourself
  • 19. 3.2 MODELING WITH RECURRENCE A computer system considers a string of decimal digits a valid codeword if it contains an even number of 0 digits. For instance, 1230407869 is valid, whereas 120987045608 is not valid. Let an be the number of valid n-digit codewords. Find a recurrence relation for an. Let an : the number of valid n-digit codewords Then; an = (number of valid n-digit codewords obtained by adding a digit other than 0 at the end of a valid string of length n – 1) + (number of valid n-digit codewords obtained by adding a digit 0 at the end of an invalid string of length n – 1) With initial condition; a1 = 9, there are 10 one-digit strings and only one the string 0 not valid Example 3.7: Codeword enumeration Solution:   1 1 1 1 1 9 10 8 10 n n n n n n a a a a          
  • 20. 3.2 MODELING WITH RECURRENCE A valid codeword of length n can be formed by: A) Adding a digit other than 0 at the end of a valid string of length n – 1 - This can be done in nine ways. Hence, a valid string with n digits can be formed in this manner in ways. B) Adding a digit 0 at the end of an invalid string of length n – 1 - This produces a string with an even number of 0 digits because the invalid string of length n – 1 has an odd number of 0 digits. The number of ways that this can be done equals the number of invalid (n – 1)-digit strings. Because there are strings of length n – 1, and are valid, then there are invalid (n – 1)-digit strings. Thus; Example 3.7: Codeword enumeration   1 1 1 1 1 1 9 10 8 10 , 9, 2 n n n n n n a A B a a a a n               1 9 n a  1 10n 1 n a  1 1 10n n a   
  • 21. 3.2 MODELING WITH RECURRENCE 6. Define recursively : 1, 4, 7, 10, 13, … 7. Beti deposits BIRR 1500 in a local savings bank at an annual interest rate of 8% compounded annually. Define recursively the compound amount an she will have in her account at the end of n years. How much will be in her account after 3 years? 8. There are n students at a class. Each person shakes hands with everybody else exactly one. Define recursively the number of handshakes that occur. EXERCISE 3.1
  • 22. 3.2 MODELING WITH RECURRENCE 9. Find a recurrence relation and initial condition for the number of ways to climb n stairs if the person climbing the stairs can take one, two or three stairs at a time. How many ways can this person climb a building with eight stairs? 10. Find a recurrence relation and initial condition for the number of bit strings of length n that contain three consecutive 0s. How many bit strings of length seven contain three consecutive 0s? 11. Find a recurrence relation for the number of bit sequences of length n with an even number of 0s? EXERCISE 3.1
  • 23. 3.3 SOLVING RECURRENCE RELATION • Solve a recurrence relation using iterative method • Solve a linear homogeneous recurrence relation with constant coefficients • Solve a linear nonhomogeneous recurrence relation with constant coefficients
  • 24. • Solving the recurrence relation for a function f means finding an explicit formula for f (n). The iterative method of solving it involves two steps: – Apply the recurrence formula iteratively and look for the pattern to predict an explicit formula  Forward: start from a0 to an  Backward : start from an to a0 – Use Induction to prove that the formula does indeed hold for every possible value of the integer n. Iterative Method
  • 25. 3.3 SOLVING RECURRENCE RELATION Using the iterative method, predict a solution for the following recurrence relation with the given initial condition. Example 3.3.1 (a): Iterative Method       0 1 0 2 2 1 0 0 2 3 3 2 0 0 1 1 0 0 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ; 1 n n n n n S S S S S S S S S S S S S S S n                Solution: (FORWARD) 1 0 2 ; 1 n n S S S    Solution: (BACKWARD) 1 2 2 3 3 0 2 2 2 2 2 n n n n n n S S S S S        
  • 26. 3.3 SOLVING RECURRENCE RELATION Suppose that a person deposits Birr10,000 in a savings account at a CBE yielding 11% per year with interest compounded annually. How much will be in the account after 30 years? Let an : the amount in the account after n years Then; an = (compound amount at the end of (n -1)th years) + (interest for the nth years) an = an-1 + 0.11an-1 = 1.11 an-1 , n ≥ 1 With initial condition; a0 = 10,000 Example 3.3.2: Compound interest Solution:
  • 27. By iterative approach: Thus, after 30 years the amount in the account will be: =Birr 228,923                   0 1 0 2 2 1 0 3 3 2 0 1 0 10000 1.11 1.11 1.11 1.11 1.11 1.11 1.11 1.11 10000 n n n n a a a a a a a a a a a a           Example 3.3.2: Compound interest Solution (continue):     30 30 1.11 10000 ___________ a   PROVE BY INDUCTION !
  • 28. The number of moves is given by: By iterative approach:     1 2 2 2 2 3 2 3 3 1 2 3 1 1 2 3 2 1 2 2 1 1 2 2 1 2 2 1 2 1 2 2 2 1 2 2 2 2 1 2 2 2 2 1 2 1 n n n n n n n n n n n n n H H H H H H H                                          Example 3.3: Tower of Hanoi 1 1 2 1 ; 1 n n H H H     PROVE BY INDUCTION !
  • 29. 3.3 SOLVING RECURRENCE RELATION 1. Using iterative method, predict a solution to each of the following recurrence relation. Verify the solutions using induction • • 2. There are n students at a class. Each person shakes hands with everybody else exactly one. Define recursively the number of handshakes that occur. Solve this recurrence relation using iterative method and prove it using induction. 3. If a deposit of birr 100 is made on the first day of each month into an account that pays 6% interest per year compounded monthly, show that the amount in the account after 18 years is birr 38929. 1 0 4 ; 0 ; 1 n n a a n a n      EXERCISE 3.3.1 2 1 1 ; 1 ; 2 n n b b n a n     
  • 30. 3.3 SOLVING RECURRENCE RELATION A linear homogeneous recurrence relation of degree k with constant coefficients is a recurrence relation of the form an = c1an-1 + c2an-2 + … + ckan-k Where c1, c2,…, ck are real numbers and ck ≠ 0 Linear Homogeneous Recurrence Relations with constant coefficients Linear : The RHS is the sum of previous terms of the sequence each multiplied by a function of n. Homogeneous : No terms occur that are not multiplies of the aj s. Degree k : an is expressed in terms of the previous k terms of the sequence Constant coefficients : c1, c2,…, ck Recurrence relation : with k initial condition a0 = C0, a1 = C1, … ak-1= Ck-1
  • 31. 3.3 SOLVING RECURRENCE RELATION Linear Homogeneous Recurrence Relation Pn = (1.11) Pn-1 degree one fn = fn-1 + fn-2 degree two an = an-5 degree five Not Linear Homogeneous Recurrence Relation Hn = 2Hn-1 + 1 Bn = nBn-1 an = an-1 + a²n-2 Example 3.3.4: Linear Homogeneous RR 1. Often occur in modeling of problems 2. Can be systematically solved
  • 32. 3.3 SOLVING RECURRENCE RELATION • OUR AIM – look for the solutions of the form , where r is constant. • Note that, is a solution of the recurrence relation an = c1an-1 + c2an-2 + … + ckan-k iff . • When both sides of this equation are divided by and the RHS is subtracted from the left, we obtain a characteristic equation: • The solution of this equation are called the characteristics roots. Solving Linear Homogeneous Recurrence Relations with constant coefficients n n a r  n n a r  1 2 1 2 n n n n k k r c r c r c r        1 2 1 2 1 0 k k k k k r c r c r c r c          n k r 
  • 33. 3.3 SOLVING RECURRENCE RELATION Let c1, c2, …, ck be real numbers. Suppose that the characteristics equation has k distinct roots r1, r2, …, rk. Then a sequence {an} is a solution of the recurrence relation an = c1an-1 + c2an-2 + … + ckan-k iff for n ≥ 0 and α1, α2, …, αk constant. If the characteristic equation has several (m) repeated roots, then the solution of the recurrence relation is given by: Solving Linear Homogeneous Recurrence Relations with constant coefficients 1 1 2 2 n n n n k k a r r r        1 2 1 2 1 0 k k k k k r c r c r c r c          1 1 2 1 1 n n m n n n m k k a r nr n r r          
  • 34. 3.3 SOLVING RECURRENCE RELATION Solve the recurrence relation an = 5an-1 - 6an-2 where a0 = 4 and a1 = 7. 1) Find the general solution of the recurrence relation • the characteristic equation is given by • the characteristic roots are 2 and 3 • thus, the general solution is 2) Find the constant values, A,B and C using the initial conditions • Solving the linear system: : A = 5, B = -1 3) Thus the solution to the recurrence relation and initial conditions is . Example 3.3.5: Second-Order LHRRWCCs Solution: 5 2 3 , 0 n n n a n     2 3 n n n a A B     2 5 6 0 r r    0 1 4 2 3 7 a A B a A B      
  • 35. 3.3 SOLVING RECURRENCE RELATION Solve the recurrence relation an = 6an-1 - 11an-2 + 6an-3 where a0 = 2, a1 =5, and a2 = 15. 1) Find the general solution of the recurrence relation • the characteristic equation is given by • the characteristic roots are 1, 2 and 3 • thus, the general solution is 2) Find the constant values, A and B using the initial conditions • Solving the linear system: (A = 1, B = -1, C = 2) 3) Thus the unique solution to the recurrence relation and initial conditions is . Example 3.3.6: Higher-Order LHRRWCCs Solution: 1 2 2 3 , 0 n n n a n      1 2 3 n n n n a A B C       3 2 6 11 6 0 r r r     0 1 2 2, 2 3 5, 4 9 15 a A B C a A B C a A B C            
  • 36. 3.3 SOLVING RECURRENCE RELATION Suppose that the roots of the characteristic equation of a linear homogenous recurrence relation are 2, 2, 2, 5, 5, and 9. What is the form of general solution? Thus the general solution to the recurrence relation is Example 3.3.7: LHRRWCCs with multiple roots Solution:     2 2 2 2 2 5 5 9 2 5 9 n n n n n n n n n n a A Bn Cn D En F A Bn Cn D En F              
  • 37. 3.3 SOLVING RECURRENCE RELATION 1. What is the solution of the following recurrence relation • • • 2. Find an explicit formula for Fibonacci numbers. EXERCISE 3.3.2 1 2 0 1 2 ; 2, 7 n n n a a a a a       1 2 0 1 6 9 ; 1, 3 n n n a a a a a       1 2 3 0 1 2 3 3 ; 1, 2, 1 n n n n a a a a a a a             1 2 1 2 ; 1, 1 n n n F F F F F      
  • 38. 3.3 SOLVING RECURRENCE RELATION • A Linear Nonhomogenous recurrence relation with constant coefficients (LNHRRWCCs), that is a recurrence relation of the form an = c1an-1 + c2an-2 + … + ckan-k + F (n) . • Where – c1, c2, …, ck are real numbers – F (n) is a function not identically zero depending only n – c1an-1 + c2an-2 + … + ckan-k is called the associated homogenous recurrence relation • Example: Linear NonHomogenous Recurrence Relations with constant coefficients 2 1 2 1 n n n a a a n n        1 2 3n n n a a n    1 3 2 n n a a n   
  • 39. 3.3 SOLVING RECURRENCE RELATION Let be the general solution of c1an-1 + c2an-2 + … + ckan-k And be the particular solution of LNHRRWCCs, an = c1an-1 + c2an-2 + … + ckan-k + F (n) Then the general solution of LNHRRWCCs is given by There is no general method to find the particular solution. Solving Linear NonHomogenous Recurrence Relations with constant coefficients   p n a   h n a     h p n n n a a a  
  • 40. 3.3 SOLVING RECURRENCE RELATION Suppose that {an} satisfy the linear nonhomogenous recurrence relation And (i)When s is not a root of the characteristic equation, there is a particular solution of the form (ii) When s is a root of the characteristic equation , there is a particular solution of the form THEOREM 1 1 1 2,..., ... ( ) where , n n k n k k a c a c a F n c c c        1 1 1 0 0 1 ( ) ( ... ) where , ,..., , t t n t t t F n b n b n b n b s b b b s        1 1 1 0 ( ... ) t t n t t p n p n p n p s      1 1 1 0 ( ... ) m t t n t t n p n p n p n p s     
  • 41. 3.3 SOLVING RECURRENCE RELATION Find all the solutions of recurrence relation an = 3an-1 + 2n 1) Find the general solution of the associated linear homogenous (ALH) equation. • the ALH equation is given by an = 3an-1 • thus, the general solution is 2) Find the particular solution • Since F(n) = 2n is polynomial with degree 1, then the trial solution linear function: pn = cn + d (c and d are constant) • The equation an = 3an-1 + 2n then become • Solve for c and d will gives c = -1 and d = -3/2 • Thus, the particular solution is 3) Thus the unique solution to the recurrence relation is Example 3.3.8: LNHRRWCCs Solution:   3 h n n a A   3 3 2 n n a A n         3 1 2 0 cn d c n d n         3 2 p n a n   
  • 42. 3.3 SOLVING RECURRENCE RELATION 1. What is the solution of the following recurrence relation • • 2. What form does a particular solution of linear nonhomogeneous recurrence relation when EXERCISE 3.3.3 2 1 2 0 1 5 6 8 ; 4, 7 n n n a a a n a a        1 2 0 1 5 6 7 ; 4, 7 n n n n a a a a a          1 2 6 9 n n n a a a F n                    2 2 3 , 3 , 2 4 1 3 , 1 3 n n n n n F n F n n F n n F n n F n n       