Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
King Fahd University of Petroleum & Minerals
Information & Computer Science Department
ICS 253: Discrete Structures I
Advanced Counting Techniques
103 ICS 253: Discrete Structures I
2
Advanced Counting Techniques
Reading Assignment
• K. H. Rosen, Discrete Mathematics and Its
Applications, 6th Ed., McGraw-Hill, 2006.
• Chapter 7 (Sections 7.1 and 7.2 up to the end of
page 464)
103 ICS 253: Discrete Structures I
3
Advanced Counting Techniques
Section 7.1: Recurrence Relations
• 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 called a solution of a
recurrence relation if its terms satisfy the
recurrence relation.
103 ICS 253: Discrete Structures I
4
Advanced Counting Techniques
Examples
• Q1 pp456: Find the first five terms of the
sequence defined by each of these recurrence
relations and initial conditions.
a) an = 6an – 1, a0 = 2
c) an = an – 1 + 3an – 2, a0 = 1, al = 2
e) an = an – 1 + an – 3, a0 = 1, al = 2, a2 = 0
103 ICS 253: Discrete Structures I
5
Advanced Counting Techniques
Examples
• Q4 pp 456: Show that the sequence {an} is a
solution of the recurrence relation
an = – 3an – 1 + 4an – 2
if
a) an = 0.
b) an = 1.
c) an = (– 4)n.
d) an = 2(– 4)n + 3.
103 ICS 253: Discrete Structures I
6
Advanced Counting Techniques
Examples
• Suppose that a person deposits $10,000 in a
savings account at a bank yielding 11% per
year with interest compounded annually. How
much will be in the account after 30 years?
103 ICS 253: Discrete Structures I
7
Advanced Counting Techniques
Examples
• 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 such bit strings are there of length
five?
103 ICS 253: Discrete Structures I
8
Advanced Counting Techniques
Examples
• Q23, pp458: Find a recurrence relation for the
number of bit strings of length n that contain
a pair of consecutive 0s.
• What are the initial conditions?
• How many bit strings of length seven contain two
consecutive 0s?
103 ICS 253: Discrete Structures I
9
Advanced Counting Techniques
Examples
• 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 ndigit codewords. Find a recurrence relation
for an.
103 ICS 253: Discrete Structures I
10
Advanced Counting Techniques
Examples
• Find a recurrence relation for Cn, the number
of ways to parenthesize the product of n + 1
numbers, x0 . xl . x2 . . . . . xn , to specify the
order of multiplication.
• What is C2? C3?
• This sequence is called the Catalan Numbers.
103 ICS 253: Discrete Structures I
11
Advanced Counting Techniques
Section 7.2:Solving Linear Recurrence Equations
• We will only consider solving linear
homogeneous recurrence equations with
constant coefficients.
• Linear nonhomogeneous recurrence relations
with constant coefficients are ommitted.
• It will be enough for us, especially those related
to estimating the complexity of recursive
algorithms.
103 ICS 253: Discrete Structures I
12
Advanced Counting Techniques
Solving Linear Homogeneous Recurrence
Relations with Constant Coefficients
• A linear homogeneous recurrence relation of
degree k with constant coefficients is a recurrence
relation of the form
an c1an 1 c 2an 2 ... c k an k
where c1, c2, . . . , ck are real numbers, and ck 0.
Advanced Counting Techniques
13
103 ICS 253: Discrete Structures I
Solving Linear Homogeneous Recurrence
Relations with Constant Coefficients
• Theorem: Let c1, c2, . . . , ck be real numbers. Suppose
that the characteristic equation
r c1r
k
k 1
c 2r
k 2
... c k 0
has k distinct roots r1, r2, . . . , rk. Then a sequence
{an} is a solution of the recurrence relation
an c1an 1 c 2an 2 ... c k an k
if and only if
an r r ... r
n
1 1
n
2 2
n
k k
for n=0,1, 2, … where 1, 2, . . . , k are constants.
103 ICS 253: Discrete Structures I
14
Advanced Counting Techniques
Example 1
• Q3, pp 471: Solve these recurrence relations
together with the initial conditions given.
(d) an = 4an – 1 – 4an – 2 for n 2, a0 = 6, a1 = 8.
103 ICS 253: Discrete Structures I
15
Advanced Counting Techniques
Example 2
• Q3, pp 471: Solve these recurrence relations
together with the initial conditions given.
(f) an = 4an – 2 for n 2, a0 = 0, a1 = 4.
103 ICS 253: Discrete Structures I
16
Advanced Counting Techniques
Solving Linear Homogeneous Recurrence Relations
with Constant Coefficients
103 ICS 253: Discrete Structures I
17
Example
Advanced Counting Techniques