CS 131: Combinatoric Structures Fall 2015 Practice problems solution Instructor: Lorenzo Orecchia Assigned Exercises: 1 Generating Functions 1. Problem 1. It’s equivalent to say we need to find the coefficient of x21 to the following generating function (1 + x + ... + x6 )(1 + x2 + x4 + ... + x10 )(1 + x5 + x10 + x15 + x20 ) 2. Problem 2 Consider the generating function (1+x)n (1+x)n . By product rule of generating function, the coefficient of xn is n 2 X n . i i=0 Also (1+x)n (1+x)n = (1+x)2n , the coefficient of xn of (1+x)2n is 2n n . Therefore, the equality holds. 3. Problem 3. Since this is a summation, it leads us to do it by product of two generating functions. The coefficient of n xi of (1 − x)n is (−1)i ni and the coefficient of xi of (1 + x)n is ni = n−i . Therefore, the generation function is (1 − x)n (1 + x)n = (1 − x2 )n . Note that there is no odd x powerin this function, when n n is odd, then the closed form is 0. If n is even, the closed form is (−1)n/2 n/2 . 4. problem 4 Note, the whole problem we will use the generalized binomial coefficient formula in HW11. 4 7 (a)(x2 + x3 + x4 + ...)4 = x8 (1 + x + x2 + ...) . The problem is equivalent to find the coefficient x of −4 2 4 −4 (1 + x + x + ...) = (1 − x) which is 7 (−1) (b)(x7 + x8 + x9 + ...)6 = x42 (1 + x + x2 + ...)6 = x42 (1 − x)−6 , The answer is the coefficient of x8 in 1 (1−x)6 which is 1287 (c) 192 (d) 1/3 4 (f) Here we use the product rule of two generations functions and the generalized binomial formula. The final result is 655/4 (g) We can write the formula to be (1+(2x2 −x))9 = 1+ 91 (2x2 −x)+ 92 (2x2 −x)2 + 93 (2x2 −x)3 +.... It’s easy to see other terms have power larger than 3. The coefficient of x3 only comes from that will 9 9 2 2 2 two terms 2 (2x − x) + 3 (2x − x)3 which is -228 HW1-1 5. Problem 5 (a) the function is 6x4 (1 + x + x2 + ...) = (b) 1 + x2 + x4 + ... = 6x4 1−x 1 1−x2 (c) This can be seen as a summation of two sequences 1, 0, 1, 0, 1, 0... and 0, 2, 0, 4, 0, 8, .... The gener1 3 5 ation function of the first sequence is 1−x 2 . The second generation function is 2x + 4x + 8x + ... = √ √ 2x Therefore, the final solution is 2x(1 + 2x2 + 22 x4 + ...) = 2x(1 + ( 2x)2 + ( 2x)4 + ...) = 1−(√ 2x)2 1 1−x2 − 2x 1−2x2 (d) We can view the sequence as (1, 1, 1, 1, ...) − (0, 0, 1, 0, 0, 1, ...). The generation function of the first 1 1 sequence is 1−x and the generation function of the second sequence is 1−x The final solution is 3. 1 1 − . 3 1−x 1−x 6. Problem 6. Since each dice ranges from 1-6 and we have three of them. The generation function is (1 + x2 + x3 + ... + x6 )3 . The coefficient of x12 is −3 12 2 Recurrence Relations 7. Problem 1 (a) For two nodes, only one link is enough since they just transfer their own files and we are done. For three nodes A, B, C with files a, b, c respectively, first link A, B, then A, B has files a, b. Second link BC, then B, C has filesa, b, c. Finally, link AC, then all has files A, B, C. Therefore, a2 ≤ 3 For four nodes A, B, C, D, first link AB, second link CD, third link AC, last link BD. You can check that after those four operations, all nodes have files a, b, c, d. Therefore a4 ≤ 4 (b) For n nodes A1 , A2 , ..., An with files f1 , f2 , ..., fn respectively and n ≥ 3, we divide the nodes into two parts A1 and A2 , ..., An . First, we link A1 A2 , then A2 carries f1 , f2 . After anther an−1 links between A2 , ..., An , we know that A2 , ..., An will share all files f1 , f2 , ...fn (Since A2 has f1 already). The last step, we link A1 A2 , then all nodes have all files. In total we have 1 + an−1 + 1 = an−1 + 2 links. Therefore, an ≤ an−1 + 2. 8. Problem 2. Clearly P1 = 1, P2 = 2. We first have all permutations for n − 1 elements, now we only need decide where to insert the last element. We can have n places to insert the last element. Therefore, the recurrence relation is Pn = nPn−1 . 9. Problem 3. (a) It’s easy to calculate L3 = 4, L4 = 7, L5 = 11. (b) Proof by strong induction, Base case : n = 1, f1 + f3 = 1 + 3 = 4 = L3 . Suppose for all i ≤ n, we have Li+1 = fi−1 + fn+1 . By definition Ln+2 = Ln+1 + Ln = fn−1 + fn+1 + fn−2 + fn = fn+2 = fn . 10. Problem 4 HW1-2 (a) The generation function A(x) satisfies A(x) = 1 + 6x(A(x) − 1) − 8x2 A(x). Then A(x) = −6x + 1 2 1 = + . 2 1 − 6x + 8x 2x − 1 4x − 1 The coefficient of an = 2n+1 − 4n (b) A(x) = 5 + 16x + 7x(A(x) − 5) − 10x2 A(x), A(x) = −2 5 − 19x 3 = − . 2 1 − 7x + 10x 5x − 1 2x − 1 Therefore an = 2 ∗ 5n + 3 ∗ 2n . (c) A(x) = 1 4 + 2x 3 = + . 1 − 2x − 8x2 1 + 2x 1 − 4x Therefore an = 34n + (−2)n p (an ), then the recurrence relation becomes (d) it’s clear that all an are positive. We set bn = bn = bn−1 + 2bn−2 with b0 = b1 = 1. By above approach, the generation function B(x) satisfies 2n+1 +(−1)n 1 1 2 B(x) = 1−x−2x , and an = b2n . 2 = 3(x+1) − 3(2x−1) . Therefore, bn = 3 (e) it’s clear that all an are positive. We can take log2 function on both sides of the equality. which means we have log(an ) = 1/2(log(an−1 ) + log(an−2 )). Set bn = log(an ), we have 2bn = bn−1 + bn−2 with b0 = 3, b1 = −1.5. By above approach, we get 3−4.5x 4 0.5 n B(x) = 2−x+x − 0.5 an = 2bn 2 = x+2 + x−1 therefore,bn = 2(−0.5) 11. Problem 5 7 7 0 + 2 + 7 4 + 7 6 12. Problem 6 (a)First put the top n − 1 to the third peg, which need Tn−1 steps. Then put the largest disk to the second peg. After that, we use another Tn−1 steps to put the disks on third peg to the first peg. Then we move the biggest disk to the third peg. At last, using another Tn−1 steps to move disks on first peg to the third peg. In total we have Tn = 3Tn−1 + 2. (b) Tn = 3n − 1. Base step: clearly, T1 = 2, we move the only disk to peg 2 and then move it to peg 3. Suppose Tn−1 = 3n−1 − 1, by (a) Tn = 3Tn−1 + 2 = 3n − 1. (c) For each disk you have three places to go. Once the positions of disks are fixed, there is only one way to arrange it in that peg. In total there are 3n different agrrangements. (d) By (b), we need 3n − 1 movements to finish the job, therefore this will let us see 3n allowable arrangements which is exactly the same of the number is (c). HW1-3
© Copyright 2026 Paperzz