Combiatorics Sum ad Product Rules Problem: How to cout without coutig. How do you figure out how may thigs there are with a certai property without actually eumeratig all of them. Sometimes this requires a lot of cleveress ad deep mathematical isights. But there are some stadard techiques. That s what we ll be studyig. Example 1: I New Hampshire, licese plates cosisted of two letters followed by 3 digits. How may possible licese plates are there? Aswer: 26 choices for the first letter, 26 for the secod, 10 choices for the first umber, the secod umber, ad the third umber: 26 2 10 3 = 676, 000 Example 2: A travelig salesma wats to do a tour of all 50 state capitals. How may ways ca he do this? Aswer: 50 choices for the first place to visit, 49 for the secod,... : 50! altogether. Chapter 4 gives geeral techiques for solvig coutig problems like this. Two of the most importat are: 1 2 The Sum Rule: If there are (A) ways to do A ad, distict from them, (B) ways to do B, the the umber of ways to do A or B is (A) + (B). This rule geeralizes: there are (A) + (B) + (C) ways to do A or B or C I Sectio 4.8, we ll see what happes if the ways of doig A ad B are t distict. The Product Rule: If there are (A) ways to do A ad (B) ways to do B, the the umber of ways to do A ad B is (A) (B). This is true if the umber of ways of doig A ad B are idepedet; the umber of choices for doig B is the same regardless of which choice you made for A. Agai, this geeralizes. There are (A) (B) (C) ways to do A ad B ad C 3 Some Subtler Examples Example 3: If there are Seators o a committee, i how may ways ca a subcommittee be formed? Two approaches: 1. Let N 1 be the umber of subcommittees with 1 seator (), N 2 the umber of subcommittees with 2 seator (( 1)/2),... Accordig to the sum rule: N = N 1 + N 2 + + N It turs out that N k =! k!( k)! ( choose k); this is discussed i Sectio 4.4 A subtlety: What about N 0? Do we allow subcommittees of size 0? How about size? The problem is somewhat ambiguous. If we allow subcommittees of size 0 ad, the there are 2 subcommittees altogether. This is the same as the umber of subsets of the set of Seators: there is a 1-1 correspodece betwee subsets ad subcommittees. 2. Simpler method: Use the product rule! 4
Each seator is either i the subcommittee or out of it: 2 possibilities for each seator: 2 2 2 = 2 choices altogether Geeral moral: I may combiatorial problems, there s more tha oe way to aalyze the problem. How may ways ca the full committee be split ito two sides o a issue? This questio is also ambiguous. If we care about which way each Seator voted, the the aswer is agai 2 : Each subcommittee defies a split + vote (those i the subcommittee vote Yes, those out vote No); ad each split + vote defies defies a subcommittee. If we do t care about which way each Seator voted, the aswer is 2 /2 = 2 1. This is a istace of the Divisio Rule. 5 6 Copig with Ambiguity More Examples If you thik a problem is ambiguous: 1. Explai why 2. Choose oe way of resolvig the ambiguity 3. Solve the problem accordig to your iterpretatio Make sure that your iterpretatio does t reder the problem totally trivial Example 4: How may legal cofiguratios are there i Towers of Haoi with rigs? Aswer: The product rule agai: Each rig gets to vote for which pole it s o. Oce you ve decided which rigs are o each pole, their order is determied. The total umber of cofiguratios is 3 Example 5: How may distiguishable ways ca the letters of computer be arraged? How about discrete? For computer, it s 8!: 8 choices for the first letter, for the secod,... Is it 8! for discrete? Not quite. There are two e s Suppose we called them e 1, e 2 : There are two versios of each arragemet, depedig o which e comes first: discre 1 te 2 is the same as discre 2 te 1. Thus, the right aswer is 8!/2! 7 8
Divisio Rule: If there is a k-to-1 correspodece betwee of objects of type A with objects of type B, ad there are (A) objects of type A, the there are (A)/k objects of type B. A k-to-1 correspodece is a oto mappig i which every B object is the image of exactly k A objects. Permutatios A permutatio of thigs take r at a time, writte P(,r), is a arragemet i a row of r thigs, take from a set of distict thigs. Order matters. Example 6: How may permutatios are there of 5 thigs take 3 at a time? Aswer: 5 choices for the first thig, 4 for the secod, 3 for the third: 5 4 3 = 60. If the 5 thigs are a,b,c,d,e, some possible permutatios are: abc abd abe acb acd ace adb adc ade aeb aec aed... I geeral P(,r) =! = ( 1) ( r + 1) ( r)! 9 10 Combiatios More Examples A combiatio of thigs take r at a time, writte C(,r) or ( ) r ( choose r ) is ay subset of r thigs from thigs. Order makes o differece. Example 7: How may ways are there of choosig 3 thigs from 5? Aswer: If order mattered, the it would be 5 4 3. Sice order does t matter, are all the same. abc,acb,bac,bca,cab,cba For way of choosig three elemets, there are 3! = 6 ways of orderig them. Therefore, the right aswer is (5 4 3)/3! = 10: abc abd abe acd ace ade bcd bce bde cde Example 8: How may full houses are there i poker? A full house has 5 cards, 3 of oe kid ad 2 of aother. E.g.: 3 5 s ad 2 K s. Aswer: You eed to fid a systematic way of coutig: Choose the deomiatio for which you have three of a kid: 13 choices. Choose the three: C(4, 3) = 4 choices Choose the deomiatio for which you have two of a kid: 12 choices Choose the two: C(4, 2) = 6 choices. Altogether, there are: 13 4 12 6 = 3744 choices I geeral C(,r) =! = ( 1) ( r + 1)/r! ( r)!r! 11 12
0! More Questios It s useful to defie 0! = 1. Why? 1. The we ca iductively defie ( + 1)! = ( + 1)!, ad this defiitio works eve takig 0 as the base case istead of 1. 2. A better reaso: Thigs work out right for P(, 0) ad C(, 0)! How may permutatios of thigs from are there? P(,) =! ( )! =! 0! =! How may ways are there of choosig out of? 0 out of? =!!0! = 1 =! 0 0!! = 1 Q: How may ways are there of choosig k thigs from {1,...,} if 1 ad 2 ca t both be chose? (Suppose,k 2.) A: First fid all the ways of choosig k thigs from C(, k). The subtract the umber of those ways i which both 1 ad 2 are chose: This amouts to choosig k 2 thigs from {3,...,}: C( 2,k 2). Thus, the aswer is Q: What if order matters? C(,k) C( 2,k 2) A: Have to compute how may ways there are of pickig k thigs, two of which are 1 ad 2. P(, k) k(k 1)P( 2, k 2) 13 14 Q: How may ways are there to distribute four distict balls evely betwee two distict boxes (two balls go i each box)? A: All you eed to decide is which balls go i the first box. C(4, 2) = 6 Q: What if the boxes are idistiguishable? A: C(4, 2)/2 = 3. Combiatorial Idetities There all lots of idetities that you ca form usig C(,k). They seem mysterious at first, but there s usually a good reaso for them. Theorem 1: If 0 k, the Proof: C(,k) = C(,k) = C(, k).! k!( k)! =! ( k)!( ( k))! = C(, k) Q: Why should choosig k thigs out of be the same as choosig k thigs out of? A: There s a 1-1 correspodece. For every way of choosig k thigs out of, look at the thigs ot chose: that s a way of choosig k thigs out of. This is a better way of thikig about Theorem 1 tha the combiatorial proof. 15 16
Theorem 2: If 0 < k < the = k 1 k + 1 k 1 Proof 1: (Combiatorial) Suppose we wat to choose k objects out of {1,...,}. Either we choose the last oe () or we do t. 1. How may ways are there of choosig k without choosig the last oe? C( 1, k). 2. How may ways are there of choosig k icludig? This meas choosig k 1 out of {1,..., 1}: C( 1,k 1). Proof 2: Algebraic... Note: If we defie C(,k) = 0 for k > ad k < 0, Theorems 1 ad 2 still hold. 17