Generalized Product Rule• Let Q be a set of length-k sequences • if n1 possible 1st elements, n2 possible 2nd elements for each first entry, n3 possible 3rd elements for each 1st & 2nd e
Trang 1Counting Subsets
Trang 2• How many arrangements of n = 52 cards?
• First card can be any of 52
• Second card can be any of the remaining 51
• …
• Once you have chosen 51 there is only one choice for the last
• So by the product rule, n ∙ (n-1) ∙ (n-2) ∙ … ∙ 2.1 = n!
Trang 3How Many 4-Letter Words Using Each Letter at Most Once?
• 26 choices for first letter
• Only 25 for second letter
• 24 for third letter
• 23 for fourth letter
• So 26∙25∙24∙23
• or 26!/22!
Trang 4Generalized Product Rule
• Let Q be a set of length-k sequences
• if n1 possible 1st elements, n2 possible 2nd elements (for each first entry), n3 possible 3rd elements (for each 1st & 2nd
entry, ) then,
• |Q| = n1⋅n2⋅⋅⋅nk
Trang 5How Many Hands with 5 Cards?
• I.e., how many 5-element subsets of a set with 52 elements?
• We know there are 52! sequences of 52 cards
• Each sequence uniquely identifies a set of 5 cards: the first 5
• Many-to-one mapping from sequences of 52 cards to sets of 5 cards!
Trang 6• map sequence a1a2a3a4…a52 to set {a1,a2,a3,a4,a5}
• How many different sequences map to the same set?
• Any way of permuting the first 5 elements maps to the same set (5! ways)
• For each of those, any way of permuting the last 47 elements maps
to the same set
a1a2a3a4a5
any permutation
6 4 7 4 8
a6… α52
ανψ περµ υτατιον6 7 4 8 4
Trang 7Counting Subsets
• By the product rule, 5!∙47! different sequences map to the same set
• Therefore the number of 5-element subsets of a set of 52 elements is
• The number of ways of picking 5 cards to include is the same as the number of ways of picking 47 cards to omit!52!
5!47! = 52
5
52 47
Trang 8“n Choose m”
• The number of m-element subsets of a set of size n is
n m
=
ν !
µ !( ν − µ !) =
ν
ν − µ
Trang 9lec 10W.9
Counting Doughnut Selections
From 5 kinds of doughnuts
select a dozen.
let A ::= all selections of
12 doughnuts
00
chocolate
lemon
sugar
glazed
plain
(none)
3/22/19
Trang 10B ::= 16-bit words with four 1’s
Counting Doughnut Selections
00
chocolate
lemon
sugar
glazed
plain
0011000000100100
Bijection A↔B so |A|=|B|
Trang 11• # of 16-bit-strings with 4 1’s = # of ways of choosing 4 from the set of possible positions {1, …, 16} =
16 4
Trang 12How Many Poker Hands (5 cards) with 2 Jacks?
• ways of picking three non-jacks
• ways of picking two jacks
• So by the product rule the number of hands with exactly 2 jacks is
48
3
4 2
48 3
γ 4 2
=
48!⋅ 4!
3!⋅ 45!⋅2!⋅2!
= 103776
Trang 13FINIS