CS3203 #5 6/9/04 Jaak J Parekh
Admiistrivia Exam o Moday All slides should be up We ll try ad have solutios for HWs #1 ad #2 out by Friday I kow the HW is due o the same day; ot much I ca do, uless you guys would strogly prefer the midterm o Weds. Exam format
Coutig, product rule Logical extesio of algebraic defiitios we ve see Combiatorics is fudametal to may problems How may passwords ca a particular scheme have? Product rule: If a procedure ca be broke dow ito a sequece of two tasks, there are 1 2 ways of doig the combiatio. 1 AND 2 Ca geeralize for m tasks
Product rule examples There are three available flights from Idiaapolis to St. Louis ad, regardless of which of these flights is take, there are five available flights from St. Louis to Dallas. I how may ways ca a perso fly from Idiaapolis to St. Louis to Dallas? A certai type of push-butto door lock requires you to eter a code before the lock will ope. The lock has five buttos, umbered 1, 2, 3, 4 ad 5. If you must choose a etry code that cosists of a sequece of four digits, with repeated umbers allowed, how may etry codes are possible? If you must choose a etry code that cosists of a sequece of four digits, with o repeated digits allowed, how may etry codes are possible? If aswers are large, do t bother multiplyig them out
Sum rule If a first task ca be doe 1 ways ad a secod task i 2 ways, but they caot be doe at the same time, there are 1 + 2 ways of doig oe of these tasks. 1 or 2 Also ca geeralize for m Geerally ituitive A studet ca choose a computer project from oe of three lists. The three lists cotai 23, 15, ad 19 possible projects. How may possible projects are there to choose from?
Set equivaleces For fiite sets, cartesia product: A 1 A A = A A L 2 L m 1 2 A m Number of differet subsets of a fiite set, i.e., P(S) = 2 S. For disjoit sets, # of ways to choose a elemet from oe of the sets: A A + 1 2 L Am = A1 + A2 + L A m Commoality makes additio much harder
More complicated coutig problems Combie rules, ad be clever Fid the umber of strigs of legth 10 of letters of the alphabet with o repeated letters that cotai o vowels. 21. 20. 13. 12. that begi with a vowel. 5. 25 17 that have C ad V at the eds (i either order) Add the two subsets, each of which are 24. 23 18. 17. that have vowels i the first two positios. 5. 4. 24. 23 18. 17 Use slots ad diagram out!
Aother example Te me ad te wome are to stad i a row. Fid the umber of possible rows. 20*19* *1, or 20! Fid the umber of possible rows if o two people of the same sex stad adjacet. 10*10*9*9* *2*2*1*1 ways for MFMF ad double if you iclude FMFM Fid the umber of possible rows if Beryl, Carol, ad Darryl wat to stad ext to each other (i some order, such as Carol, Beryl, ad Darryl, or Darryl, Beryl, ad Carol). 3! possibilities for DCB Make them oe slot out of 18 18! possibilities, so 3!*18!
Iclusio-exclusio priciple Whe two tasks ca be doe at the same time, caot use the sum rule twice, as it duplicates the # of ways to do both tasks Istead, add the umber of ways to do each of the two tasks ad subtract the umber of ways to do both. Aki to uioig two odistict sets: A1 A2 = A1 + A2 A1 A2
Oe more example Fid the umber of strigs of legth 10 of letters of the alphabet with repeated letters allowed that cotai o vowels: 21 10 begi with a vowel: 5*26 9 have vowels i the first two positios: 5 2 *26 8 begi with C ad ed with V: 26 8 begi with C or ed with V: (2*26 9 ) 26 8 (i.e., subtract out the ad case)
Tree diagrams Useful way of drawig out possibilities But ot really practical for large cases Example: how may bit strigs of legth four do ot have two cosecutive oes? Aswer o page 309
Pigeohole priciple Extraordiarily simple cocept that s hard to visualize sometimes If k+1 or more objects are placed ito k boxes, the there is at least oe box cotaiig two or more of the objects. Souds very obvious, but I ay group of 27 Eglish words, there must be at least two that begi with the same letter. At least two of us are bor i the same seaso. At least two people i NYC have the same umber of hairs o their head. Prove that i ay group of three positive itegers, there are at least two whose sum is eve. Cosider two pigeoholes, labeled EVEN ad ODD. If three positive itegers are placed i these pigeoholes, oe of the pigeoholes must have at least two itegers (say a ad b) i it. Thus, a ad b are either both eve or both odd. I either case, a+b is eve.
Geeralized Pigeohole priciple If N objects are placed ito k boxes, the there is at least oe box cotaiig N/k objects. I a class of size 100, there are at least 9 who were bor i the same moth. How may cards must be selected from a stadard deck of 52 cards to guaratee that at least three cards of the same suit are chose? (9, sice 9/4 = 3) Each studet is classified as a member of oe of the followig classes: Freshma, Sophomore, Juior, Seior. Fid the miimum umber of studets who must be chose i order to guaratee that at least eight belog to the same class. (29) Numerous elegat applicatios; a few are listed i the book
Permutatios We ve approached this implicitly, but ow let s come up with some more precise defiitios. A permutatio of a set of distict objects is a ordered arragemet of these objects. If r elemets are to be ordered, r-permutatio. P(,r) = umber of r-permutatios of a set with distict elemets is = (-1)(-2) (-r+1). P(,) =! A class has 30 studets erolled. I how may ways ca four be put i a row for a picture? all 30 be put i a row for a picture? all 30 be put i two rows of 15 each (that is, a frot row ad a back row) for a picture? How may permutatios of ABCDEFGH cotai the strig ABC? ABC is oe possibility, DEFGH are possibilities. So arrage 6 items, or 6!. Fallig power otatio
Combiatios If orderig does t matter, the use combiatios Subsets Formula is C (, r)! r!( r)! Note secod otatio also called biomial coefficiet Note that P(,r) = C(,r) + P(r,r) i.e., applicatio of orderig. Also, C(,r) = C(,-r) Simple math Idea: whe orderig does t matter, who you keep i is equivalet to who you keep out C(,0) = C(,) = 1 = r =
Examples How may ways are there to select 5 players from a 10-member teis team to make a trip to a match at aother school? How may ways are there to choose a committee of size five cosistig of three wome ad two me from a group of te wome ad seve me? C(10,3) * C(7,2) = 2,520 How may ways ca you take a deck of cards ad Break them ito four equal piles A, B, C, D; C(52,13)*C(39,13)*C(26,13)*C(13,13) Four equal piles that are ot labeled Divide the previous oe by 4! (i.e., get rid of the labelig permutatios)
Biomial coefficiets r-combiatios occur as coefficiets i the expasio of powers of biomial expressios, such as (a+b). Biomial theorem: if x, y are variables ad is a oegative iteger = = + j j j y x j y x 0 ) ( y xy y x y x x + + + + + = 1 2 2 1 1 2 1 0 L
Examples What is the expasio of (x+y) 4? Write the expasio of (x+2y) 3. What is the coefficiet of a 17 b 23 i the expasio of (3a-7b) 40? C(40,23)3 17 (-7) 23
Corollaries Proof: just use x = 1, y = 1 Implies C(,0)+C(,2)+C(,4)+ = C(,1)+C(,3)+C(,5)+ Some other iterestig tidbits i the book = = k k 0 2 ( ) = = k k k 0 0 1
+ k Pascal s Idetity 1 = + k 1 Complete with idetities, ca be used to recursively defie biomial coefficiets less work tha calculatig factorial Ca therefore be used to form a triagle, where the th row cosists of coefficiets C(,k), k = 0, 1,, k
A few more idetities Vadermode s idetity Idea: two ways to select r elemets out of the uio of m i oe set ad i aother. Either literal uio (additio), or repeatedly pick k from the first set ad r-k from the secod set ad vary k (ad combie usig product rule). Corollary: = = k k 0 2 2 = = + r k k k r m r m 0
Geeralized permutatios ad combiatios Permutatios with repetitio How may strigs of legth ca be formed from the Eglish alphabet? r r-permutatios from objects Combiatios with repetitio C(+r-1, r) r-combiatios from a set with elemets whe repetitio is allowed How may ways to select 5 bills from a cash box cotaiig $1, $2, $5, $10, $20, $50, $100, where order does ot matter, ad that there are at least 5 idetical bills of each type = 7, r = 5, so C(11, 5) = 462
Aother example How may solutios does the equatio x 1 +x 2 +x 3 = 11 have, give x are oegative itegers? Select 11 items from a set with three elemets, i.e., x 1 items of type oe, x 2 items of type 2, x 3 items of type 3. So, 11- combiatios of 3 elemets with repetitio (i.e., ulimited umbers of those three elemets), i.e., C(13,11) = C(13, 2) = 78.
Bigger example A bakery sells four kids of cookies: chocolate, jelly, sugar, ad peaut butter. You wat to buy a bag of 30 cookies. Assumig that the bakery has at least 30 of each kid of cookie, how may bags of 30 cookies could you buy if you must choose: at least 3 chocolate cookies ad at least 6 peaut butter cookies. 21 udefied cookies of 4 types, so select 4 elemets i 21 combiatios, or C(24,21) = C(24,3) Note that it feels backwards but legit. Model as c+j+s+p = 21 if you prefer.
Cot d. exactly 3 chocolate cookies ad exactly 6 peaut butter cookies. = 2, r = 21 (oly variace is jelly vs. sugar), so C(22,21) = C(22,1) = 22. at most 5 sugar cookies. C(33,30) { umber of possible combiatios of all} C(27,24) { umber of possibilities with 6 sugar cookies } or C(33,3) - C(27,3) = 2,925 at least oe of each of the four types of cookies. = 4, r = 26, so C(29,26) = C(29,3) = 3,654
Permutatios with idistiguishable objects Ex: How may strigs ca be made by reorderig SUCCESS? Note that orderig matters, but ot amogst the three Ss ad two Cs. Need to combie multiple combiatios How may ways ca you choose three places to put the Ss amogst the 7 slots? C(7,3); P(7,3) would imply the three Ses have a differece. Similarly, C(4,2) for Cs after Ss have bee placed. U ca be placed i C(2,1) ways, ad E ca oly be placed i oe positio Ad : product rule aswer is 420.
Aother example A jar cotais 30 peies, 20 ickels, 20 dimes, ad 15 quarters. (The cois of each deomiatio are cosidered to be idetical.) Fid the umber of ways to put all 85 cois i a row. C(85,30)*C(55,20)*C(35,20)*1 Fid the umber of possible hadfuls of 12 cois. Sice we have more cois of each type tha 12, simply the previous class of problems (combiatios with repetitio), or C(15,12) = C(15,3) = 455. I how may ways ca 7 of the 8 letters i CHEMISTS be put i a row? Oly S idistiguished, but eed to cosider both cases where oe ad two Ses are kept C(7,2)*P(6,5) + C(7,1)*P(6,6) = 6*(7!/2!) + 7!
Easier way Where you have objects, with 1 istiguishable objects of type 1, 2 of type 2, etc. ca be represeted by!!! L 1 2 k! Similar to distributig distiguishable objects ito distiguishable boxes How may ways are there to distribute hads of 5 cards to each of four players from the stadard deck of 52 cards? C(52,5)C(47,5)C(42,5)C(37,5) = 52!/(5!*5!*5!*5!*32!) ote the leftover box
Lots of techiques! Trick is to figure out which oe Remember ad vs or for product vs sum rules Remember orderig for permutatios vs. combiatios For the rest, eed to apply some ituitio ad careful thought Lots of useful equatios o page 340-341
Next time Start chapter 5 probability Midterm