CS103X: Discrete Structures Homewor 4 Solutios Due February 22, 2008 Exercise 1 10 poits. Silico Valley questios: a How may possible six-figure salaries i whole dollar amouts are there that cotai at least three distict digits? b Secod Silico Valley questio: What is the umber of six-figure salaries that are ot multiples of either 3, 5, or 7. Solutio a First ote that there are 999, 999 100, 000 1 900, 000 total possible salaries. Let us ow cout the complemet case - umber of six-figure salaries that cotai at most two distict digits. There are 9 salaries with 1 distict digit 111111, 222222,..., 999,999. Now let us cout the salaries that have exactly two distict digits. Sice the first digit caot be 0, we eed to cosider the case whe oe of the two distict digits is 0 differetly. So suppose oe of the two distict digits is 0, the we have 9 choices for the other digit. The first positio eeds to cotai this o-zero digit ad we get to place either of the two i the last 5 positios however we wat. There are 2 5 1 differet ways to do this, sice we ca cosider a bijectio betwee 5 digit biary umbers where 0 meas that 0 is i the positio, 1 meas that the other digit is i the positio. So there are i total 9 2 5 1 differet salaries with two distict digits, oe of which is 0 sice a biary value of 11111 gives all 1 digit, we tae it out. For the case of two distict digits whe either digit is 0, we get 9 2 2 6 2. First we choose two digits, ad the similar to the 0 case, we have 2 6 2 differet ways of arragig the two umbers for two distict digits. Notice that we have have to disclude the values 000000 ad 111111, which would oly iclude 1 distict digit. Therefore, i total, we have 900, 000 9 9 2 5 1 9 2 2 6 2 897, 480 b From a there are 900,000 possible six-figure salaries. Now let us cout the umber of possible six-figure salaries that are multiples of either 3, 5, or 7. We ca subtract this umber from the total to obtai the umber of six-figure salaries that are ot multiples of either 3, 5, or 7. Let D 3, D 5, D 7 be the set of six-figure salaries that are multiples of 3,5,7 respectively. We therefore eed to fid D 3 D 5 D 7. We will use the iclusio-exclusio priciple to compute this. D 3 999,999 100,002 3 1 300, 000 D 5 999,995 100,000 5 1 180, 000 D 7 999,999 100,002 7 1 128, 572 D 3 D 5 999,990 100,005 3 5 1 60, 000 D 3 D 7 999,999 100,002 3 7 1 42, 858 D 5 D 7 999,990 100,030 5 7 1 25, 714 D 3 D 5 D 7 999,915 100,065 3 5 7 1 8, 571 1
From the iclusio-exclusio priciple: D 3 D 5 D 7 D 3 D 5 D 7 D 3 D 5 D 3 D 7 D 5 D 7 D 3 D 5 D 7 488, 571 Therefore, the umber of six-figure salaries that are ot multiples of either 3, 5, or 7 are give by: 900, 000 488, 571 411, 429 Exercise 2 15 poits. A roo o a chessboard is said to put aother chess piece uder attac if they are i the same row or colum. a How may ways are there to arrage 8 roos o a chessboard the usual 8 8 oe so that oe are uder attac? b How may ways are there to arrage roos o a chessboard so that oe are uder attac? c Imagie a three-dimesioal chess variat played o a 8 8 8 board. 512 cells overall. Call it Weir-D Chess. A battleship is a Weir-D Chess piece that ca attac ay piece that is i the same two-dimesioal layer, alog some coordiate. For example, a battleship i positio 5, 2, 6 puts cell 8, 2, 1 uder attac, but ot cell 8, 3, 1. How may ways are there to arrage 8 battleships o a Weir-D Chess board so that oe are uder attac? Give solutios with o summatio. Solutio a 8!. Cosider 8 8 board as 8 colums. I the first colum, you ca choose 8 differet positios for a roo. For the secod colum, there are oly 7 remaiig positios available, etc. The last colum will force the last roo ito positio. b. Cosider board as colums. I the first colum, you ca choose differet positios for a roo. For the secod colum, there are 1 remaiig positios available, etc dow to 1 remaiig positios for the last roo. We are placig roos, so we eed to choose which colums they are i. Thus, it is c 8! 2. Cosider a 8 8 8 cube ad cosider placig a roo o each of the 8 plaes horizotally or vertically. The first roo placed has 8 8 positios i its plae. This roo elimiates a cross sectio of all the others such that there are effectively 7 7 valid positios i each remaiig plae. Similarly, the ext roo has 7 7 positios ad leaves 6 6 valid positios i each remaiig plae. If we cotiue i this fashio, we will have 8 2 7 2... 2 2 1 2 8! 2 ways of placig the roos. Exercise 3 15 poits. A fuctio f : {1, 2,..., } {1, 2,..., m} is called mootoe odecreasig if 1 i < j fi fj. a How may such fuctios are there? b How may such fuctios are there that are surjective? c How may such fuctios are there that are ijective? 2
Solutio a There are m 1 such fuctios. Cosider the codomai {1, 2,..., m} as bis ad the domai {1, 2,..., } as balls. If a bi codomai elemet cotais a ball, it meas that oe of the elemets i the domai maps to it. Thus, if we repeset this as bis ad balls, ay orderig of the bis ad balls will give us a uique mappig from domai to codomai sice it has to be mootoe odecreasig The bijectio as follows: the smallest valued bi that has a ball must must map to the miimal domai elemet. Remove that ball ad the ew smallest valued bi that could be the same value as the bi i the previous step has a ball must map to the secod miimal domai elemet, ad so o. Now we ca apply the caoical uordered with repetitio formula. b There are mm 1 m 1 m such fuctios. Agai, if we use the balls ad bis aalogy, we have to first allocate 1 ball for each bi, ad the choose positios for the rest of the balls. Thus, m balls are left for us to put ito bis, as i the caoical uordered with repetitio problem. c There are m. Oce we choose the a set of elemets from m, we will ow the exact mappig because the fuctio must be mootoe odecreasig. Thus, we eed to determie i how may ways ca we choose elemets from m. Exercise 4 10 poits. How may ways are there to express a positive iteger as: a A sum of atural umbers? For example, if 2 ad 3 the aswer is 6, sice 2 2 0 0 0 2 0 0 0 2 1 1 0 1 0 1 0 1 1. b A sum of positive itegers? The order of the summads is importat. Imagie the summatio writte dow. Solutio a 1. Cosider each xi as a box ad there are balls. The we have the caoical uordered with repetitio. b Cosider the formula i part a. We ow have ragig from 1 to, with atleast 1 ball i each box. We allocate 1 ball i each box first, so we have balls left to place. Thus, we have 1 1 1 1 2 1 Exercise 5 10 poits. Prove either algebraically or combiatorically: a For p, 0, b p p 1 p 1 m m 1 0 Solutios a Cosider what the RHS is coutig. We are choosig p 1 elemets from 1 possible elemets. Let us umber these elemets 1, 2, 3,...,, 1. Let us cout the umber of ways to select p 1 elemets i a particular way. Suppose the maximal elemet piced is goig to be p 1. The we have p p ways of choosig the last p elemets. Now suppose the maximal elemet piced is goig 3
to be p 2. The we have p1 p ways of choosig the last p elemets. I geeral, if the maximal elemet piced is 1, the we have p ways of choosig the last p elemets. So we have p as desired. b Cosider the RHS. Let s apply Pascal s rule repeatedly: m 1 m m 1 m m 1 m 1 1 2 m m 1 m 2 m 2 1 2 3 as desired. p. m m 1 m 2 m 1... 1 2 1 m 0 Exercise 6 10 poits. Give a closed-form expressio without summatio for the followig: 2. Solutio 0 2 1 2 3 0 m 0 Exercise 7 10 poits. I a mathematics cotest with three problems, 80% of the participats solved the first problem, 75% solved the secod ad 70% solved the third. Prove that at least 25% of the participats solved all three problems. The claim might seem obvious fid a proof. Solutio Let the total umber of participats be > 0 if 0, the proof is trivial. Deote the set of people who missed the first problem by A, the set of people who missed the secod by B, ad the set who missed the third by C. We ow that A 0.8 0.2, B 0.75 0.25 ad C 0.7 0.3. We also ow, from the lecture otes, that A B C A B C 0.2 0.25 0.3 0.75 The set of people who solved all three problems is the complemet of A B C the set who missed at least oe problem, so it has size A B C 0.75 0.25 Therefore at least 25% of the participats solved all three problems. Exercise 8 10 poits. What is the umber of iteger solutios of the equatio such that 0 x i 20 for each 1 i 3? x 1 x 2 x 3 50, 4
Solutio Let us cout the complemet. At least 1 bi has more tha 20 balls. This problem may be thought of as the uordered with repetitio problem. Cosider 3 bis ad 50 balls. Without loss of geerality, let the first bi cotai at least 21 balls. The there are 29 balls remaiig. There are effectively 3 bis ad 29 balls, which maes for 293 1 29 ways of havig the first bi cotai at least 21 balls. Without loss of geerality, let the first two bis cotai at least 21 balls. The there are 8 balls remaiig. Still, there are effectively 3 bis ad 8 ball,s which maes for 83 1 8. There caot be at ay time all three bis havig at least 21 balls, as 21 3 63 > 50. Now we ca apply the iclusio-exclusio priciple. Let P {1} be the umber ways that we ca have bi 1 have more tha 20 balls, P {1, 2} be the umber of ways that we ca have bis 1 ad 2 have more tha 20 balls, etc. P {1} P {2} P {3} P {1, 2} P {1, 3} P {2, 3} P {1, 2, 3} 29 3 1 8 3 1 3 3 0 29 8 This is the complemet. I total, the umber of iteger solutios to the equatio is 503 1 50 with o restrictios. Therefore, the umber of ways to mae 0 x i 20 for each 1 i 3 is: 50 3 1 29 3 1 8 3 1 3 3 66 50 29 8 Exercise 9 10 poits. There are people at a party, ad each perso has arrived i a differet hat. The revelry leaves them slightly tipsy, so each of them goes home wearig someoe else s hat. Fid the umber of ways of puttig hats o people so that o perso is wearig his/her ow hat. Give the full proof. Solutio Refer sectio 11.2 Deragemets i lecture otes. 5