Counting Subsets Permutations • • • • • 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! How 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! 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 entry,...) then, • |Q| = n1⋅n2⋅⋅⋅nk How 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! • 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 6any4permutation 7 48 any64permutation 7 48 a1a2 a3a4 a5 a6 a52 {a1,a2 ,a3 ,a4 ,a5 } Counting 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 52! 52 52 5!47! 5 47 • The number of ways of picking 5 cards to include is the same as the number of ways of picking 47 cards to omit! “n Choose m” • The number of m-element subsets of a set of size n is n n n! m m!(n m!) n m Counting Doughnut Selections From 5 kinds of doughnuts select a dozen. let A ::= all selections of 12 doughnuts 00 (none) 000000 00 00 chocolate lemon sugar glazed plain 7/12/2016 lec 10W.9 Counting Doughnut Selections B::= 16-bit words with four 1’s 0011000000100100 00 00 1 1 000000 000000 1 00 00 100 00 chocolate lemon sugar glazed plain Bijection A↔B so |A|=|B| 7/12/2016 10 • # of 16-bit-strings with 4 1’s = # of ways of choosing 4 from the set of possible positions {1, …, 16} = 16 4 7/12/2016 11 How Many Poker Hands (5 cards) with 2 Jacks? • 48 ways 3 • 4 ways 2 of picking three non-jacks of picking two jacks • So by the product rule the number of hands with exactly 2 jacks is 48 4 48! 4! 3 g 2 3! 45! 2! 2! 103776 FINIS