1 / 43

Chapter 7 Advanced Counting Techniques

歐亞書局. Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen. Chapter 7 Advanced Counting Techniques. 歐亞書局. 7.1 Recurrence Relations 7.2 Solving Linear Recurrence Relations 7.3 Divide-and-Conquer Algorithms and Recurrence Relations

udell
Download Presentation

Chapter 7 Advanced Counting Techniques

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 歐亞書局 Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Chapter 7Advanced Counting Techniques

  2. 歐亞書局 • 7.1 Recurrence Relations • 7.2 Solving Linear Recurrence Relations • 7.3 Divide-and-Conquer Algorithms and Recurrence Relations • 7.4 Generating Functions • 7.5 Inclusion—Exclusion • 7.6 Applications of Inclusion— Exclusion P. 1

  3. 7.1 Recurrence Relations • Definition 1: 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 • Ex.1-2

  4. Modeling with Recurrence Relations • Ex.3: Compound interest • Ex.4: Rabbits and the Fibonacci numbers • Ex.5: The Tower of Hanoi • Ex.6 • Ex.7: Codeword enumeration • Ex.8

  5. FIGURE 1 (7.1) 歐亞書局 FIGURE 1 Rabbits on an Island. P. 452

  6. FIGURE 2 (7.1) 歐亞書局 FIGURE 2 The Initial Position in the Tower of Hanoi. P. 452

  7. FIGURE 3 (7.1) 歐亞書局 FIGURE 3 An Intermediate Position in the Tower of Hanoi. P. 453

  8. FIGURE 4 (7.1) 歐亞書局 FIGURE 4 Counting Bit Strings of Length n with No Two Consecutive 0s. P. 455

  9. 7.2 Solving Linear Recurrence Relations • Definition 1: A linearhomogeneous recurrence relation of degree k with constant coefficients:an=c1an-1+c2an-2+…+ckan-k,where c1,c2,…,ck are real numbers, and ck0. • Ex.1 • Pn=(1.11)Pn-1 • fn=fn-1+fn-2 • an=an-5

  10. Solving Linear Homogeneous Recurrence Relations with Constant Coefficients • an=c1an-1+c2an-2+…+ckan-k • an=rn is a solution iff rn=c1rn-1+c2rn-2+…+ckrn-k • rk-c1rk-1-c2rk-2-…-ck-1r-ck=0 • Characteristic equation • Characteristic roots • Theorem 1: Let c1 and c2 are real numbers. Suppose r2-c1r-c2=0 has two distinct roots r1 and r2. Then the sequence {an} is a solution of the recurrence relation an=c1an-1+c2an-2iffan=1r1n+ 2r2n for n=0, 1, 2, …, where 1 and 2 are constants. • Proof.

  11. Ex.3: an=an-1+2an-2, a0=2, a1=7. • Ex.4: Fibonacci numbers. • Theorem 2: Let c1 and c2 are real numbers with c20. Suppose r2-c1r-c2=0 has only one root r0. Then the sequence {an} is a solution of the recurrence relation an=c1an-1+c2an-2iffan=1r0n+ 2nr0n for n=0, 1, 2, …, where 1 and 2 are constants. • Ex. 5: an=6an-1-9an-2, a0=1, a1=6.

  12. Theorem 3: Let c1,c2,…,ck be real numbers. Suppose rk-c1rk-1-…-ck=0 has k distinct roots r1,r2,…, rk. Then the sequence {an} is a solution of the recurrence relation an=c1an-1+c2an-2+…+ckan-kiffan=1r1n+2r2n+…+krkn for n=0, 1, 2, …, where 1,2 …,k are constants. • Ex.6: an=6an-1-11an-2+6an-3, a0=2 , a1=5, a2=15.

  13. Theorem 4: Let c1,c2,…,ck be real numbers. Suppose rk-c1rk-1-…-ck=0 has t distinct roots r1,r2,…, rt with multiplicities m1,m2,…, mt such that mi>=1 and m1+m2+…+mt=k.Then the sequence {an} is a solution of the recurrence relation an=c1an-1+c2an-2+…+ckan-kiffan=(1,0+1,1n+…+1,m1-1)r1n +(2,0+2,1n+…+2,m2-1)r2n +…+(t,0+t,1n+…+t,mt-1)rtn for n=0, 1, 2, …, where i,i are constants. • Ex.7 • Ex.8: an=-3an-1-3an-2-an-3, a0=1 , a1=-2, a2=-1.

  14. Linear Nonhomogeneous Recurrence Relations with Constant Coefficients • Nonhomogeneous: • an=c1an-1+c2an-2+…+ckan-k+F(n) • Associated homogeneous recurrence relation: an=c1an-1+c2an-2+…+ckan-k • Ex.9: an=an-1+2n, an=an-1+an-2+n2+n+1, an=3an-1+n3n, an=an-1+an-2+an-3+n!

  15. Theorem 5: If {an(p)} is a particular solution of the nonhomogeneous recurrence relation with constant coefficients an=c1an-1+c2an-2+…+ckan-k +F(n), then every solution is of the form {an(p)+an(h)}, where an(h) is a solution of the associated homogeneous recurrence relation an=c1an-1+c2an-2+…+ckan-k. • Proof. • Ex.10. an=3an-1+2n, a1=3. • Ex.11: an=5an-1-6an-2+7n.

  16. Theorem 6: Suppose {an} satisfies the nonhomogeneous recurrence relation with constant coefficients an=c1an-1+c2an-2+…+ckan-k +F(n), and F(n)=(btnt+bt-1nt-1+…+b1n+b0)sn. When s is not a root of the associate recurrence relation, there is a particular solution of the form (ptnt+pt-1nt-1+…+p1n+p0)sn.When s is a root of the characteristic equation and its multiplicity is m, there is a particular solution of the form nm (ptnt+pt-1nt-1+…+p1n+p0)sn. • Ex.12: an=6an-1-9an-2+F(n), F(n)=3n, n3n, n22n, (n2+1)3n. • Ex.13: an=an-1+n.

  17. 7.3 Divide-and-Conquer Algorithms and Recurrence Relations • Divide-and-conquer algorithms • Divide: a problem of size n into a subproblems, each of size n/b • Conquer: combine the solutions of subproblems • Divide-and-conquer recurrence relation • f(n)=af(n/b)+g(n) • Ex.1: binary search • Ex.2: finding the maximum and minimum of a sequence • Ex.3: merge sort • Ex.4: fast multiplication of integers • Ex.5: fast matrix multiplication

  18. n=bk • f(n)=akf(1)+j=0..k-1ajg(n/bj) • Theorem 1: Let f be an increasing function that satisfies the recurrence relationf(n)=af(n/b)+c. Thenf(n) is O(nlogba) if a>1, O(logn) if a=1.When n=bk, f(n)=C1nlogba+C2, whereC1=f(1)+c/(a-1), C2=-c/(a-1) • Proof. • Ex. 6: f(n)=5f(n/2)+3, f(1)=7. Find f(2k). • Ex.7: binary search • Ex.8: locate the maximum and minimum elements in a seqeunce.

  19. Theorem 2 (Master Theorem): Let f be an increasing function that satisfies the recurrence relationf(n)=af(n/b)+cnd. When n=bk, Thenf(n) is O(nd) if a<bd, O(ndlogn) if a=bd, O(nlogba) if a>bd. • Ex.9: merge sort • Ex.10: fast multiplication algorithm • Ex.11: fast matrix multiplication • Ex.12: The Closest-Pair Problem

  20. FIGURE 1 (7.3) 歐亞書局 FIGURE 1 The Recursive Step of the Algorithm for Solving the Closest-Pair Problem. P. 480

  21. FIGURE 2 (7.3) 歐亞書局 FIGURE 2 Showing That There Are at Most Seven Other Points to Consider for Each Point in the Strip. P. 481

  22. 7.4 Generating Functions • To represent sequences efficiently by coding the terms of a sequence as coefficients of powers of a variable x in a formal power series • To solve recurrence relations • To prove combinatorial identities • To study properties of sequences

  23. Definition 1: The generating function for the sequence a0, a1, …, ak, … of real numbers is the infinite seriesG(x) = a0+a1x+…+akxk+…=k=0..akxk. • Ordinary generating functions • Ex.1 • Ex.2 • Ex.3

  24. Useful Facts about Power Series • Ex.4: f(x)=1/(1-x) • Ex.5: f(x)=1/(1-ax) • Theorem 1: Let f(x)=k=0..akxk and g(x)=k=0..bkxk. Then f(x)+g(x)=k=0..(ak+bk)xk and f(x) g(x)=k=0..(j=0..kajbk-j)xk and. • It’s valid only for power series that converge in an interval. • Ex.6: f(x)=1/(1-x)2.

  25. Definition 2: Let u be a real number and k a nonnegative integer. Then the extended binomial coefficient (u,k) is defined by (u,k)=u(u-1)…(u-k+1)/k! if k>0, or 1 if k=0. • Ex.7: (-2, 3), (1/2, 3) • Ex.8: (-n, r)=(-1)rC(n+r-1,r) • Theorem 2: (The Extended Binomial Theorem) Let x be a real number with |x|<1 and let u be a real number. Then(1+x)u= k=0..(u,k)xk. • Ex.9: (1+x)-n, (1-x)-n.

  26. TABLE 1 (7.4) 歐亞書局 P. 489

  27. Counting Problems and Generating Functions • Counting the r-combinations from n elements when repetition is allowed • e1+e2+…+en=C • Ex.10: e1+e2+e3=17, e1:2-5, e2:3-6, e3:4-7. • Ex.11 • Ex.12 • Ex.13: k-combinations from n elements. • Ex.14: r-combinations from n elements when repetition is allowed. • Ex.15: select r objects of n different kinds if we must select at least one object of each kind.

  28. Using Generating Functions to Solve Recurrence Relations • Ex.16: ak=3ak-1, a0=2. • Ex.17: an=8an-1+10n-1, a1=9.

  29. Proving Identities via Generating Functions • Ex.18

  30. 7.5 Inclusion-Exclusion • The principle of inclusion-exclusion • |AB|=|A|+|B|-|AB| • Ex.1: (Fig.1) • Ex.2: (Fig.2) • Ex.3

  31. FIGURE 1 (7.5) 歐亞書局 FIGURE 1 The Set of Students in a Discrete Mathematics Class. P. 501

  32. FIGURE 2 (7.5) 歐亞書局 FIGURE 2 The Set of Positive Integers Not Exceeding 1000 Divisible by Either 7 or 11. P. 501

  33. For three sets: (Fig. 3) • |AB C|=|A|+|B|+|C|-|AB|-|BC|-|CA|+|AB C| • Ex. 4 (Fig. 4)

  34. FIGURE 3 (7.5) 歐亞書局 FIGURE 3 Finding a Formula for the Number of Elements in the Union of Three Sets. P. 502

  35. FIGURE 4 (7.5) 歐亞書局 FIGURE 4 The Set of Students Who Have Taken Courses in Spanish, French, and Russian. P. 503

  36. Theorem 1: (The Principle of Inclusion-Exclusion) Let A1, A2, …, An be finite sets. Then|A1A2  … An|=i=1..n|Ai|-i,j=1..n|AiAj|+i,j,k=1..n|AiAj Ak|-…+(-1)n+1|A1A2  …An|. • Ex.5

  37. 7.6 Applications of Inclusion-Exclusion • An alternative form of inclusion-exclusion • To solve: the number of elements in a set that have none of n properties P1, P2, …, Pn. • Let Ai be the subset that have property Pi. • The number of elements with all the properties Pi1, Pi2, …, Pik: N(Pi1, Pi2, Pik). • N(P1’,P2’,…,Pn’)=N-|A1A2  … An|=N-i=1..nN(Pi)+i,j=1..nN(PiPj)-i,j,k=1..nN(PiPjPk)+…+(-1)nN(P1P2…Pn). • Ex.1

  38. The Sieve of Eratosthenes • To find all primes not exceeding a specified positive integer • For example, the primes not exceeding 100 • P1: divisible by 2 • P2: divisible by 3 • P3: divisible by 5 • P4: divisible by 7

  39. TABLE 1 (7.6) 歐亞書局 P. 508

  40. The Number of Onto Functions • Ex.2 • Theorem 1: Let m and n be positive integers with m>=n. Then, there arenm-C(n,1)(n-1)m+C(n,2)(n-2)m+…+(-1)n-1C(n,n-1)1monto functions from a set with m elements to a set with n elements. • =n!S(m,n), where S(m,n) is a Stirling number of the second kind • Ex.3

  41. Derangement • Derangement: a permutation of n objects that leave no objects in their original positions • Ex.4: The Hatcheck problem (later) • Ex.5 • Let Dn denote the number of derangements of n objects, D3=2 • Theorem 2: The number of derangements of a set with n elements is Dn=n![1-1/1!+1/2!-1/3!+…+(-1)n1/n!] • Proof.

  42. TABLE 2 (7.6) 歐亞書局 P. 512

  43. Thanks for Your Attention!

More Related