Top Banner
ICS 253: Discrete Structures I Advanced Counting Techniques King Fahd University of Petroleum & King Fahd University of Petroleum & Minerals Minerals Information & Computer Science Department Information & Computer Science Department
17

ICS 253: Discrete Structures I

Dec 31, 2015

Download

Documents

paul-mcintyre

King Fahd University of Petroleum & Minerals Information & Computer Science Department. ICS 253: Discrete Structures I. Advanced Counting Techniques. Reading Assignment. K. H. Rosen, Discrete Mathematics and Its Applications , 6 th Ed., McGraw-Hill, 2006. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ICS 253: Discrete Structures I

ICS 253: Discrete Structures I

Advanced Counting Techniques

King Fahd University of Petroleum & MineralsKing Fahd University of Petroleum & Minerals

Information & Computer Science DepartmentInformation & Computer Science Department

Page 2: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

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)

2

Page 3: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

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.

3

Page 4: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

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

4

Page 5: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

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.

5

Page 6: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

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?

6

Page 7: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

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?

7

Page 8: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

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?

8

Page 9: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

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 n-digit codewords. Find a recurrence relation for an.

9

Page 10: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

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.

10

Page 11: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

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.

11

Page 12: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

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

where c1, c2, . . . , ck are real numbers, and ck 0.

12

1 1 2 2 ...n n n k n ka c a c a c a

Page 13: ICS 253: Discrete Structures I

Advanced Counting Techniques103 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

has k distinct roots r1, r2, . . . , rk. Then a sequence {an} is a solution of the recurrence relation

if and only if

for n=0,1, 2, … where 1, 2, . . . , k are constants.

13

1 21 2 ... 0k k k

kr c r c r c

1 1 2 2 ...n n n k n ka c a c a c a

1 1 2 2 ...n n nn k ka r r r

Page 14: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

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.

14

Page 15: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

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.

15

Page 16: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

Solving Linear Homogeneous Recurrence Relations with Constant Coefficients

16

Page 17: ICS 253: Discrete Structures I

Advanced Counting Techniques103 ICS 253: Discrete Structures I

Example

17