Loading in 5 sec....

Counting Elements of Disjoint Sets: The Addition RulePowerPoint Presentation

Counting Elements of Disjoint Sets: The Addition Rule

- 89 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about ' Counting Elements of Disjoint Sets: The Addition Rule' - ryder-watts

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

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

- 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/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/Exclusion

- By the Inclusion/Exclusion Rule,
|ABCD|

= |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/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/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/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/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

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/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/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?

Download Presentation

Connecting to Server..