Inclusion/Exclusion Principle

Inclusion/Exclusion Principle
Sandy Irani
ICS 6D
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?
Inclusion/Exclusion Example
• How many strings of length 6 over the alphabet
{A, B, C} start with a C or a B?
• How many strings of length 6 over the alphabet
{A, B, C} start with a C or end with a C?
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.
Inclusion/Exclusion Example
• How many 5-card hands from a standard
playing hand have exactly one King or exactly
one Ace (or both)?
*
Inclusion/Exclusion Example
• How many strings of length 6 over the alphabet
{A, B, C} have at least 5 consecutive A’s?
Inclusion/Exclusion with 3 Sets
• |A ∪ B ∪ C| = |A| + |B| + |C|
- |A ∩ B| - |A ∩ C| - |B ∩ C|
+ |A ∩ B ∩ C|
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?
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?
Inclusion/Exclusion Example
• How many strings of length 6 over the alphabet
{A, B, C, D, E} have at least 4 consecutive A’s?
*
Incl/Excl 3 Sets
• How many integers in the range 1 through 42
are divisible by 2, 3, or 7?
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|
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?
Incl/Excl and counting by complement
• How many 5-card hands have at least one ace
or at least one queen (inclusive or)?
More Donut Selection
• How many ways to select 20 donuts from 4 varieties. There is
a large selection of glazed and maple. But there are only 5
chocolates left and only 3 jelly left. (# chocolates must be ≤ 5)
Number of selections
with at most 5
chocolate donuts and
at most 3
Jelly donuts
=
Number of
selections
with no
restrictions
-
Number of selections
with more than 5
chocolate donuts
OR more than 3
chocolate donuts