Download presentation
Presentation is loading. Please wait.
Published byMyra Cook Modified over 6 years ago
1
Counting by Complement and the Inclusion/Exclusion Principle
Sandy Irani ICS 6D
2
5-card Hands How many 5-card hands have exactly 1 club?
3
5-card Hands How many 5-card hands have at least one club?
4
Counting by Complement
Set S of items. Let P ⊆ S be the set of items in S that have some particular propery: |S| - |P| = |P| Set of all 5-card hands with at least one club Set of all 5-card hands Set of all 5-card hands with no clubs
5
Counting by Complement: Examples
How many length 8 strings over the alphabet {a, b, c} have at least one “a”?
6
Counting by Complement: Examples
A software team has 10 senior member and 10 junior members. Must select a set of 4 people to work on a project. How many selections have at least one junior member?
7
- More Donut Selection =
How many ways to select 20 donuts from 4 varieties. There is a large selection of glazed, jelly, and maple. But there are only 5 chocolates left. (# chocolates must be ≤ 5) Number of selections with at more than 5 chocolate donuts Number of selections with at most 5 chocolate donuts Number of selections with no restrictions - =
8
Solution to Sums of Variables
How many solutions are there to the following equation, where each variable xi is a non-negative integer? x1 + x2 + x3 + x4 = 12 x2 ≤ 3
9
Solution to Sums of Variables
How many solutions are there to the following equation, where each variable xi is a non-negative integer? x1 + x2 + x3 + x4 = 12 x2 ≤ 3 and x4 ≥ 2
10
The Sum Rule (Review) For finite sets A1, A2,…, An ,
If the sets are pairwise disjoint (Ai ∩ Aj = φ, for i≠j) then |A1 ∪ A2 ∪ … ∪ An|= |A1| + |A2| + … + |An| What if the sets are not pairwise disjoint?
11
Inclusion/Exclusion 2 Sets
|A ∪ B| = |A| + |B| - |A ∩ B| S general population of elements P1 is the set of elements with property 1 P2 is the set of elements with property 2 How many elements in S have property 1 or 2 (inclusive or)? | P1 ∪ P2| = Number of elements with property 1 + Number of elements with property 2 - Number of elements with both properties.
12
Inclusion/Exclusion Example
How many 5-card hands from a standard playing hand have exactly one King or exactly one Ace (or both)? ∪
13
Inclusion/Exclusion Example
How many strings of length 6 over the alphabet {A, B, C} start with a C or end with a C? (inclusive or)
14
Inclusion/Exclusion Example
How many strings of length 6 over the alphabet {A, B, C} start with a B or C? (inclusive or)
15
Inclusion/Exclusion Example
How many strings of length 6 over the alphabet {A, B, C} have at least 5 consecutive A’s?
16
Inclusion/Exclusion with 3 Sets
|A ∪ B ∪ C| = |A| + |B| + |C| - |A ∩ B| - |A ∩ C| - |B ∩ C| + |A ∩ B ∩ C|
17
Inclusion/Exclusion with 3 Sets
Drug test on a population of 1000 people 122 people develop symptom A 88 people develop symptom B 112 people develop symptom C 27 people develop symptom A and B 29 people develop symptom A and C 32 people develop symptom B and C 10 people develop all three symptoms How many people get at least one symptom?
18
Inclusion/Exclusion with 3 Sets
Line up of 7 people: Mother, Father, 3 sons, 2 daughters How many line-ups are there in which the mother is next to at least one of her 3 sons?
19
Inclusion/Exclusion Example
How many strings of length 6 over the alphabet {A, B, C} have at least 4 consecutive A’s?
20
Incl/Excl 3 Sets How many integers in the range 1 through 42 are divisible by 2, 3, or 7?
21
Inclusion/Exclusion with 4 Sets
|A ∪ B ∪ C ∪ D | = |A| + |B| + |C| + |D| - |A ∩ B| - |A ∩ C| - |B ∩ C| - |A ∩ D| - |B ∩ D| - |C ∩ D| + |A ∩ B ∩ C| + |A ∩ B ∩ D| + |A ∩ C ∩ D| + |B ∩ C ∩ D| - |A ∩ B ∩ C ∩ D|
22
Inclusion/Exclusion with 4 Sets
Suppose you are using the inclusion-exclusion principle to compute the number of elements in the union of four sets. Each set has 15 elements. The pair-wise intersections have 5 elements each. The three-way intersections have 2 elements each. There is only one element in the intersection of all four sets. What is the size of the union? What is the size of the union?
23
Incl/Excl and counting by complement
How many 5-card hands have at least one ace or at least one queen (inclusive or)?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.