230 likes | 299 Views
Counting by Complement and the Inclusion/Exclusion Principle. Sandy Irani ICS 6D. 5-card Hands. How many 5-card hands have exactly 1 club?. 5-card Hands. How many 5-card hands have at least one club?. Counting by Complement. Set S of items.
E N D
Counting by Complementand theInclusion/Exclusion Principle Sandy Irani ICS 6D
5-card Hands • How many 5-card hands have exactly 1 club?
5-card Hands • How many 5-card hands have at least one club?
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
Counting by Complement: Examples • How many length 8 strings over the alphabet {a, b, c} have at least one “a”?
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?
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 - =
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
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
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 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} start with a C or end with a C? (inclusive or)
Inclusion/Exclusion Example • How many strings of length 6 over the alphabet {A, B, C} start with a B or C? (inclusive or)
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} 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)?