Counting elements of disjoint sets the addition rule
This presentation is the property of its rightful owner.
Sponsored Links
1 / 13

Counting Elements of Disjoint Sets: The Addition Rule PowerPoint PPT Presentation


  • 53 Views
  • Uploaded on
  • Presentation posted in: General

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.

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


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

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

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.


Example inclusion exclusion1

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}.


Example inclusion exclusion2

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|.


Example inclusion exclusion3

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.


Example inclusion exclusion4

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.


Example inclusion exclusion5

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


Example inclusion exclusion6

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.


Primes cpp

Primes.cpp

  • Primes.cpp


Example inclusion exclusion7

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?


Example inclusion exclusion8

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.


Example inclusion exclusion9

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?


  • Login