Unit 8 (Recurrence Relations)
Unit 8 (Recurrence Relations)
1
Example 1
•• Find
a recurrence relation and give initial conditions for the
number of bit strings of length n that do not have two
consecutive zeros.
Solution: Let denote the number of bit strings of length n that do
not have two consecutive zeros. Note that where is the number
of bit strings of length n that do not have two consecutive zeros
and end with 1 and is the number of bit strings of length n that
do not have two consecutive zeros and end with 0. Suppose that .
A bit string of the type counted by can be obtained by putting a 1
at the end of a bit string of length that does not have two
consecutive zeros. Thus, .
2
Example 1 (continued)
•A bit string of the type counted by is obtained
from a bit string of length that does not have
two consecutive zeros by inserting a 10 at the
end. Thus, . Hence, we obtain the recurrence
relation . This holds for .
It is easily seen that and . The following values
are easily computed.
, , and .
3
Example 2
•• A string of decimal digits is said to be valid provided that it has an even
number of zeros. Let be the number of valid n digit strings of decimal
digits. Find a recurrence relation for .
Solution: Suppose that . If the last digit of a valid n digit string is non-
zero, it can be formed from a valid digit string by putting a non-zero digit
at the end. This gives us valid n digit strings with last digit non-zero.
If the last digit of a valid n digit string is zero, it can be formed by putting
a zero at the end of an invalid digit string. Thus, the number of valid n
digit strings with last digit zero is the same as the number of invalid digit
strings which is .
Hence, for .
Remark: Note that .
4
Linear recurrence relations
•• A linear homogeneous recurrence relation of degree k
with constant coefficients is a recurrence relation of the
form
where
are constants with .
• Thus, for example, is a linear homogeneous recurrence
relation of degree 2 with constant coefficients while
is a linear
homogeneous recurrence relation of degree 3 with
constant coefficients.
5
Solving linear homogeneous recurrence relations of
degree 2 with constant coefficients (distinct roots)
• Theorem
A: Let and be constants. Suppose
that the characteristic equation has two
distinct roots and . Then, the sequence is a
solution of the recurrence
if and only if
for all integers
where and are constants.
6
Example 3
• Solve the recurrence if and .
Solution: The characteristic equation is which
has roots and . Thus, for some constants and .
Using gives while gives . Solving these two
equations give and . Hence, for all .
7
Solving linear homogeneous recurrence relations
of degree 2 with constant coefficients (equal roots)
• Theorem
B: Let and be constants with
Suppose that the characteristic equation has
equal roots with both roots equal to . Then, the
sequence is a solution of the recurrence
if and only if
for all integers
where and are constants.
8
Example 4
• Solve
the recurrence with initial conditions
and .
Solution: The characteristic equation is which
has equal roots given by . Thus, for some
constants and . The initial conditions yield and
giving . Hence, for all non-negative integers n.