1 / 13

Counting Elements of Disjoint Sets: The Addition Rule

Counting Elements of Disjoint Sets: The Addition Rule. Lecture 30 Sections 6.3 Tue, Mar 20, 2007. Example: Inclusion/Exclusion. How many primes are there between 1 and 100? The non-primes must be multiples of 2, 3, 5, or 7, since the square root of 100 is 10. A Lemma.

ryder-watts
Download Presentation

Counting Elements of Disjoint Sets: The Addition Rule

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. Counting Elements of Disjoint Sets: The Addition Rule Lecture 30 Sections 6.3 Tue, Mar 20, 2007

  2. Example: Inclusion/Exclusion • How many primes are there between 1 and 100? • The non-primes must be multiples of 2, 3, 5, or 7, since the square root of 100 is 10.

  3. A Lemma • Lemma: Let n and d be positive integers. There are n/d multiples of d between 1 and n, where x represents the “floor” of x.

  4. Example: Inclusion/Exclusion • Let A = {n | 1 n 100 and 2 divides n}. • Let B = {n | 1 n 100 and 3 divides n}. • Let C = {n | 1 n 100 and 5 divides n}. • Let D = {n | 1 n 100 and 7 divides n}.

  5. Example: Inclusion/Exclusion • By the Inclusion/Exclusion Rule, |ABCD| = |A| + |B| + |C| + |D| – |A B| – |A C| – |A D| – |B C| – |B D| – |C D| + |A B C| + |A B C| + |A B C| + |A B C| – |A B C  D|.

  6. Example: Inclusion/Exclusion • However, • A B = {n | 1 n 100 and 6 | n}. • A B C = {n | 1 n 100 and 30 | n}. • B C D = {n | 1 n 100 and 105 | n}. • And so on.

  7. Example: Inclusion/Exclusion • Therefore, • |A| = 100/2 = 50. • |A B| = 100/6 = 16. • |A B C| = 100/30 = 3. • |B C D| = 100/105 = 0. • And so on.

  8. Example: Inclusion/Exclusion • The number of multiples of 2, 3, 5, and 7 is (50 + 33 + 20 + 14) – (16 + 10 + 7 + 6 + 4 + 2) + (3 + 2 + 1 + 0) – (0) = 78

  9. Example: Inclusion/Exclusion • This count includes 2, 3, 5, 7, which are prime. • This count does not include 1, which is not prime. • Therefore, the number of primes is 100 – 78 + 4 – 1 = 25.

  10. Primes.cpp • Primes.cpp

  11. Example: Inclusion/Exclusion • How many integers from 1 to 1000 are multiples of 6, 10, or 15? • Let A = {n | 1 n 100 and 6 divides n}. • Let B = {n | 1 n 100 and 10 divides n}. • Let C = {n | 1 n 100 and 15 divides n}. • What is A B? A C? B C? • What is A B C?

  12. Example: Inclusion/Exclusion • |A| = 1000/6 = 166. • |B| = 1000/10 = 100. • |C| = 1000/15 = 66. • |A B| = 1000/30 = 33. • |A C| = 1000/30 = 33. • |B C| = 1000/30 = 33. • |A B C| = 1000/30 = 33. • Therefore, 266 numbers from 1 to 1000 are multiples of 6, 10, or 15.

  13. Example: Inclusion/Exclusion • How many 8-bit numbers have either • 1 in the 1st and 2nd positions, or • 1 in the 1st and 3rd positions, or • 1 in the 2nd, 3rd, and 4th positions?

More Related