Uivesity of Hawaii ICS141: Discete Mathematics fo Compute Sciece I Dept. Ifomatio & Compute Sci., Uivesity of Hawaii Ja Stelovsy based o slides by D. Bae ad D. Still Oigials by D. M. P. Fa ad D. J.L. Goss Povided by McGaw-Hill ICS 141: Discete Mathematics I Fall 2011 13-1
Uivesity of Hawaii Lectue 25 Chapte 5. Coutig 5.3 Pemutatios ad Combiatios 5.4 Biomial Coefficiets 5.5 Geealized Pemutatios ad Combiatios ICS 141: Discete Mathematics I Fall 2011 13-2
Pemutatios Uivesity of Hawaii A pemutatio of a set S of distict elemets is a odeed sequece that cotais each elemet i S exactly oce. E.g. {A, B, C} six pemutatios: ABC, ACB, BAC, BCA, CAB, CBA A odeed aagemet of distict elemets of S is called a -pemutatio of S. The umbe of -pemutatios of a set with S elemets is! P, ) 1) 2) 1), 0. )! P,)!/ )!!/0!! Note: 0! 1) ICS 141: Discete Mathematics I Fall 2011 13-3
Pemutatio Examples Uivesity of Hawaii Example: Let S {1, 2, 3}. The aagemet 3, 1, 2 is a pemutatio of S 3! 6 ways) The aagemet 3, 2 is a 2-pemutatio of S 3 23!/1! 6 ways) Example: Thee is a amed uclea bomb plated i you city, ad it is you job to disable it by cuttig wies to the tigge device. Thee ae 10 wies to the device. If you cut exactly the ight thee wies, i exactly the ight ode, you will disable the bomb, othewise it will explode! If the wies all loo the same, what ae you chaces of suvival? P10,3) 10 9 8 720, so thee is a 1 i 720 chace that you ll suvive! ICS 141: Discete Mathematics I Fall 2011 13-4
Moe Pemutatio Examples Uivesity of Hawaii Example 6: Suppose that a sales woma has to visit eight diffeet cities. She must begi he tip i a specified city, but she ca visit the othe seve cities i ay ode she wishes. How may possible odes ca the saleswoma use whe visitig these cities? Fist city is detemied, ad the emaiig seve ca be odeed abitaily: 7! 7 6 5 4 3 2 1 5040 Example 7: How may pemutatios of the lettes ABCDEFGH cotai the stig ABC? ABC must occu as a bloc, i.e. coside it as oe object The, it ll be the umbe of pemutatios of six objects ABC, D, E, F, G, H), which is 6! 720 ICS 141: Discete Mathematics I Fall 2011 13-5
Aothe Example Uivesity of Hawaii How may ways ae thee to pic a set of 3 people fom a goup of 6? Thee ae 6 choices fo the fist peso, 5 fo the secod oe, ad 4 fo the thid oe, so thee ae 6 5 4 120 ways to do this. This is ot the coect esult! Fo example, picig peso C, the peso A, ad the peso E leads to the same goup as fist picig E, the C, ad the A. Howeve, these cases ae couted sepaately i the above equatio. So how ca we compute how may diffeet subsets of people ca be piced that is, we wat to disegad the ode of picig)? ICS 141: Discete Mathematics I Fall 2011 13-6
Combiatios Uivesity of Hawaii A -combiatio of elemets of a set S is a uodeed selectio of elemets fom the set. Thus, a -combiatio is simply a subset T S with membes, T. Example: S {1, 2, 3, 4}, the {1, 3, 4} is a 3-combiatio fom S Example: How may distict 7-cad hads ca be daw fom a stadad 52-cad dec? The ode of cads i a had does t matte. Notatio: C, ) o, whee 52 ad 7 ICS 141: Discete Mathematics I Fall 2011 13-7
13-8 ICS 141: Discete Mathematics I Fall 2011 Uivesity of Hawaii Calculate C, ) Coside that we ca obtai the -pemutatio of a set i the followig way: Fist, we fom all the -combiatios of the set thee ae C, ) such -combiatios) The, we geeate all possible odeigs i each of these -combiatios thee ae P, ) such odeigs i each case). Theefoe, we have: )!!!! 1 )!!! 1) 1) ), ), ), ), ), ), P P C P C P
13-9 ICS 141: Discete Mathematics I Fall 2011 Uivesity of Hawaii Combiatios The umbe of -combiatios of a set with S elemets is )!!!! )!!/ ), ), ), P P C [ ]! )!!! ) )!! ), C Note that C, ) C, ) Because choosig the membes of T is the same thig as choosig the ) omembes of T.
Combiatio Example I Uivesity of Hawaii How may distict 7-cad hads ca be daw fom a stadad 52-cad dec? The ode of cads i a had does t matte. Aswe: C52, 7) P52, 7) / P7, 7) 52! / 7! 45!) 52 51 50 49 48 47 46) / 7 6 5 4 3 2 1) 17 10 7 8 2 52 17 10 7 47 46 133,784,560 ICS 141: Discete Mathematics I Fall 2011 13-10
Combiatio Example II Uivesity of Hawaii C4, 3) 4, sice, fo example, the 3-combiatios of a set {1, 2, 3, 4} ae {1, 2, 3}, {1, 3, 4}, {2, 3, 4}, {1, 2, 4}. C4, 3) P4, 3) / P3, 3) 4! / 3! 1!) 4 3 2) / 3 2 1) 4 How may ways ae thee to pic a set of 3 people fom a goup of 6 disegadig the ode of picig)? C6, 3) 6! / 3! 3!) 6 5 4) / 3 2 1) 20 Thee ae 20 diffeet goups to be piced ICS 141: Discete Mathematics I Fall 2011 13-11
Combiatio Example III Uivesity of Hawaii A socce club has 8 female ad 7 male membes. Fo today s match, the coach wats to have 6 female ad 5 male playes o the gass. How may possible cofiguatios ae thee? C8, 6) C7, 5) {P8, 6) / P6, 6)} {P7, 5) / P5, 5)} {8!/ 2! 6!)} {7!/ 2! 5!)} {8 7) / 2!} {7 6) / 2!} 28 21 588 ICS 141: Discete Mathematics I Fall 2011 13-12
Biomial Coefficiets Uivesity of Hawaii Expessios of the fom C, ) ae also called biomial coefficiets ICS 141: Discete Mathematics I Fall 2011 Coefficiets of the expasio of powes of biomial expessios Biomial expessio is a simply the sum of two tems such as x y Example: 3 x y) x xx xxx x 3 y) x xy xxy C3,0) x 3x 2 3 y yx y) x xyx C3,1) x 3xy 2 y) yy) x xyy 2 y y 3 y) yxx yxy C3,2) xy 2 yyx yyy C3,3) y 13-13 3
13-14 ICS 141: Discete Mathematics I Fall 2011 Uivesity of Hawaii The Biomial Theoem Let x ad y be vaiables, ad let be a oegative itege. The To obtai a tem of the fom x j y j, it is ecessay to choose j) x s fom the tems, so that the othe j tems i the poduct ae y s. Theefoe, the coefficiet of x j y j is C, j) C, j). The biomial theoem gives the coefficiets of the expasio of powes of biomial expessios. ) j j j y x j y xy y x y x x y x 0 1 2 2 1 1 2 1 0
Examples Uivesity of Hawaii a b) 9 the coefficiet of a 5 b 4 C9, 4) The coefficiet of x 12 y 13 i the expasio of 2x 3y) 25 By biomial theoem 25 j 0 25 j 25 j j 2x 3y) ) 25 2x) 3y) The coefficiet of x 12 y 13 is obtaied whe j 13 C25,13) 2 12 3) 13 25! 2 13! 12! 12 3 13 x y z) 9 the coefficiet of x 2 y 3 z 4 C9, 2) C7, 3) ICS 141: Discete Mathematics I Fall 2011 13-15
13-16 ICS 141: Discete Mathematics I Fall 2011 Uivesity of Hawaii T Poof: T Poof: It implies that: is a positive itege. whee, 0 1) 0 Coollaies whee isa oegative itege., 2 0 0 0 1) 1) 1 1)) 1 0 0 0 0 1 1 1) 1 2 5 3 1 4 2 0
13-17 ICS 141: Discete Mathematics I Fall 2011 Uivesity of Hawaii T Poof: Coollaies cot.) isa oegative itege. whee, 3 2 0 2 2 1 2) 1 3 0 0
Geealized Pemutatios ad Uivesity of Hawaii Combiatios Pemutatios ad combiatios allowig epetitios. How may stigs of legth ca be fomed fom the Eglish alphabet? How may diffeet ways ae possible whe we select a doze douts fom a box that cotais fou diffeet ids of douts? Pemutatios whee ot all objects ae distiguishable. The umbe of ways we ca eaage the lettes of the wod MISSISSIPPI ICS 141: Discete Mathematics I Fall 2011 13-18
Pemutatios with Repetitios Uivesity of Hawaii Theoem 1: The umbe of -pemutatios of objects with epetitio allowed is. Poof: Thee ae ways to select a elemet of the set fo each of positios with epetitio allowed. By the poduct ule, the aswe is give as multiples of. Example: How may stigs of legth ca be fomed fom the Eglish alphabet? Aswe: 26 ICS 141: Discete Mathematics I Fall 2011 13-19
Combiatios with Repetitios Uivesity of Hawaii A example How may ways ae thee to select fou pieces of fuit fom a bowl cotaiig apples, oages, ad peas if thee ae at least fou pieces of each type of fuit i the bowl? I this case, the ode i which the pieces ae selected does ot matte, oly the types of fuit, ot the idividual piece, matte. ICS 141: Discete Mathematics I Fall 2011 13-20
Combiatios with Repetitios Uivesity of Hawaii Example Rephased: The umbe of 4-combiatios with epetitio allowed fom a 3-elemet set {apple, oage, pea} All fou i same type: 4 apples, 4 oages, 4 peas [3 ways] Thee i same type: two cases fo each of 3 apples, 3 oages, 3 peas [2*36 ways] Two diff. pais with each pai i same type [3 ways] Oly oe pai i same type [3 ways] Total 15 ways Ca be geealized: The umbe of ways to fill 4 slots fom 3 categoies with epetitio allowed ICS 141: Discete Mathematics I Fall 2011 13-21
Example Uivesity of Hawaii How may ways ae thee to select five bills fom a cash box cotaiig $1 bills, $2 bills, $5 bills, $10 bills, $20 bills, $50 bills, ad $100 bills? The ode i which the bills ae chose does t matte The bills of each deomiatio ae idistiguishable At least five bills of each type C7 15, 5) C11, 5) 11! / 5! 6!) 462 ICS 141: Discete Mathematics I Fall 2011 13-22
Combiatios with Repetitios Uivesity of Hawaii Theoem 2: The umbe of -combiatios fom a set with elemets with epetitio allowed is: C 1, ) C 1, 1) Othe epesetatios with the same meaig # of ways to fill slots fom categoies with epetitio allowed # of ways to select elemets fom categoies of elemets with epetitio allowed ICS 141: Discete Mathematics I Fall 2011 13-23
Poof of Theoem 2 Uivesity of Hawaii Repeset each -combiatios fom a set with elemets with epetitio allowed by a list of 1 bas ad stas. 1 bas: used to ma off diffeet cells categoies) stas: each sta i i-th cell if ay) epesets a elemet that is selected fo the i-th categoy # of diffeet lists that cotaiig 1 bas ad stas # of ways to chose the positios to place the stas fom 1 positios [C 1, )] # of ways to chose the 1 positios to place the 1 bas fom 1 positios [C 1, 1)] ICS 141: Discete Mathematics I Fall 2011 13-24
Moe Examples Uivesity of Hawaii How may ways ca I fill a box holdig 100 pieces of cady fom 30 diffeet types of cady? Solutio: Hee #stas 100, #bas 30 1, so thee ae C10029,100) 129! / 100! 29!) diffeet ways to fill the box. How may ways if I must have at least 1 piece of each type? Solutio: Now, we ae educig the #stas to choose ove to 100 30) stas, so thee ae C7029, 70) 99! / 70!29!) ICS 141: Discete Mathematics I Fall 2011 13-25
Whe to Use Geealized Combiatios Uivesity of Hawaii Besides categoizig a poblem based o its ode ad epetitio equiemets as a geealized combiatio, thee ae a couple of othe chaacteistics which help us sot: I geealized combiatios, havig all the slots filled i by oly selectios fom oe categoy is allowed; It is possible to have moe slots tha categoies. ICS 141: Discete Mathematics I Fall 2011 13-26
Moe Itege Solutios & Restictios Uivesity of Hawaii How may itege solutios ae thee to: a b c d 15, whe a -3, b 0, c -2 ad d -1? I this case, we alte the estictios ad equatio so that the estictios go away. To do this, we eed each estictio 0 ad balace the umbe of slots accodigly. Hece a -33, b 0, c -22 ad d -11, yields a b c d 15321 21 So, thee ae C214 1,21) C24,21) C24,3) 24x23x22)/3x2) 2024 solutios. ICS 141: Discete Mathematics I Fall 2011 13-27
Distibutig Objects ito Distiguishable Boxes Uivesity of Hawaii Distiguishable o labeled) objects to distiguishable boxes How may ways ae thee to distibute hads of 5 cads to each of fou playes fom the stadad dec of 52 cads? C52,5)C47,5)C42,5)C37,5) Idistiguishable o ulabeled) objects to distiguishable boxes How may ways ae thee to place 10 idistiguishable balls ito 8 distiguishable bis? C810-1, 10) C17,10) 17! / 10!7!) ICS 141: Discete Mathematics I Fall 2011 13-28
Distibutig Distiguishable Objects Uivesity of Hawaii ito Idistiguishable Boxes How may ways ae thee to put 4 diffeet employees ito 3 idistiguishable offices, whe each office ca cotai ay umbe of employees? all fou i oe office: C4,4) 1 thee oe: C4,3) 4 two two: C4,2)/2 3 two oe oe: C4,2) 6 ICS 141: Discete Mathematics I Fall 2011 13-29
Distibutig Idistiguishable Uivesity of Hawaii Objects ito Idistiguishable Boxes How may ways ae thee to pac 6 copies of same boo ito 4 idetical boxes, whee each box ca cotai as may as six boos? List # of boos i each box with the lagest # of boos, followed by #s of boos i each box cotaiig at least 1 boo, i ode of deceasig # of boos i a box. 6 5,1 4,2 4,1,1 3,3 3,2,1 3,1,1,1 2,2,2 2,2,1,1 ICS 141: Discete Mathematics I Fall 2011 13-30
Aothe Combiatio Example Uivesity of Hawaii How may outes ae thee fom the lowe left coe of a squae gid to the uppe ight coe if we ae esticted to tavelig oly to the ight o upwad. Solutio R: ight U: up oute RUURRURU : a stig of R s ad U s Ay such stig ca be obtaied by selectig positios fo the R s, without egad to the ode of selectio, fom amog the 2 available positios i the stig ad the fillig the emaiig positio with U s. Thus thee ae C2,) possible outes. ICS 141: Discete Mathematics I Fall 2011 13-31
Pascal s Idetity Uivesity of Hawaii Let ad be positive iteges with. The Poof Let X be a set with elemets. Let a X. The C1, ) is the umbe of -elemet subsets of Y X {a} Y cotais 1 elemets). Now the -elemet subsets of Y ca be divided ito two disjoit classes: 1. subsets of Y ot cotaiig a -elemet subsets of X C,) 2. subsets of Y cotaiig a 1)-elemet subsets of X togethe with a C, 1) C1, ) C, 1) C, ) ICS 141: Discete Mathematics I Fall 2011 1 1 13-32
Pascal s Tiagle Uivesity of Hawaii We ca wite the biomial coefficiet i tiagula fom ICS 141: Discete Mathematics I Fall 2011 13-33
Vademode s Idetity Uivesity of Hawaii Let m,, ad be oegative iteges with ot exceedig eithe m o. The Poof: Suppose that thee ae m items i oe set ad items i a secod set. The the total umbe of ways to pic elemets fom the uio of these sets is m ICS 141: Discete Mathematics I Fall 2011 m 0 m 13-34
13-35 ICS 141: Discete Mathematics I Fall 2011 Uivesity of Hawaii Poof cot. Aothe way to pic elemets fom the uio is to pic elemets 0 < < ) fom the secod set ad the elemets fom the fist set. By the poduct ule, this ca be doe i The total umbe of ways to pic elemets fom the uio also equals m m m 0
13-36 ICS 141: Discete Mathematics I Fall 2011 Uivesity of Hawaii Moe Theoems Coollay Theoem 4: Let ad be oegative iteges with <. The oegative itege. a is whee, 2 2 0 j j 1 1