McGill University Faculty of Science Solutions to Practice Final Examination Math 40 Discrete Structures Time: hours Marked out of 60
Question. [6] Prove that the statement (p q) (q r) (p r) is a contradiction using truth tables or the rules of logic. Then draw a Venn diagram showing clearly why this is a contradiction. Solution. Using truth tables, we have a contradiction, since the last column displays false for every truth assignment to p, q and r. p q r p q q r p r (p q) (q r) (p r) F F F T F F F F F T T T F F F T F T T F F F T T T F F F T F F F F F F T F T F T T F T T F T T F F T T T T F T F Using the rules of logic: (p q) (q r) (p r) ( p q) (q r) (p r) ( p q) (p r) (q r) associativity ( p (p r)) (q p r) (q r) distributivity (( p p) r) (q p r) (q r) associativity 0 (q p r) (q r) contradiction (q p r) (q r) absorption (q r p) (q r) (q r) commutativity 0 (q r) contradiction 0 contradiction. Using Venn Diagrams: q r p q p r There are no regions which contain all three colourings, therefore the given statement is a contradiction.
Question. [6] Let n be a positive integer. Prove that n k(n k) = k= ( n + ). Solution. We ll recall from class that n k= k = ( n ) (it would be given as a hint in the actual exam). Now we prove the given statement by induction. For n =, both sides are zero so we are done. Now suppose n k(n k) = k= and we prove the given formula. Well ( ) n n n n k(n k) = k(n k) + k. k= k= The last term is ( ( n ) by what we recalled from class, and the first term is n ) by induction. So n k(n k) = k= This completes the proof. = = = ( ) n + ( ) n = k= n(n )(n ) 6 n(n ) ((n ) + ) 6 (n + )n(n ) ( ) 6 n +. + n(n )
Question. [6] (a) Write down the number of compositions of n into k non-negative parts, where n and k are non-negative integers and n k. Solution. This is bookwork, the answer is ( ) n+k k. (b) State the multinomial formula, for the number of ordered partitions of an n element set into parts of sizes n, n,..., n k. Then determine the number of ways the letters of the word BANANA can be rearranged. n! Solution. First part is n!n!...n k := ( ) n! n n... n k (bookwork). The answer to the second part is ( 6 ) = 60.
Question 4. [6] Solve the recurrence equation a n = a n + a n where a = a =. Solution. This is the Fibonacci equation, so its bookwork. 4
Question 5. [6] (a) Prove that if p is a prime number, and 0 < k < p, then p ( p k). Find an example to show this is not true if p is not prime. Bookwork (b) Prove that the product of primes greater than n and less than n is less than ( n n ) for any n. Solution. The same proof as in (a) shows that if n < p < n and p is prime, then p ( ) n n. But if primes p, p,..., p k divide a number, so does their product. So if we multiply all the primes between n and n together, we get a number which divides ( ) n n, and is therefore less than ( ) n n. 5
Question 6. [6] (a) Determine 7 0 modulo. Solution. Since is prime, we can use Fermat a p mod p for any prime p and a 0. In particular, 7 0 mod 0. (b) Determine 7 0 modulo 49. Solution. Since 7 0 = (49) 5, the answer is zero. (c) Determine 7 0 modulo 0. Solution. Notice 7 0 = (49) 5 ( ) 5 = () 5 modulo 0. Now () = mod 0 so () 5 = () 7 9 so the answer is 9. 6
Question 7. [6] (a) Find the Prüfer code for the labelled tree shown below. The root of the tree is the vertex labelled zero. 0 5 7 9 4 6 8 Figure : A labelled tree Solution. The rule is: create two sequences one on top of the other as follows. At each step, pick the smallest non-zero leaf, and write that number in the top sequence. Below it, right the label of the vertex in the tree that it is joined to. The very last edge, which will join to zero, is not written down, so if the tree has n vertices, the sequences have length n. Then the lower sequence is the Prüfer code. Prüfer Code ( 0 9 5 0 9 0) 7
Question 7 continued... (b) Draw the tree with Prüfer code (0, 8, 0,, 8, 6,, 0,,,, 8). Solution. First add zero at the end of the Prüfer code and then create another sequence from the Prüfer code as follows: above each number in the Prüfer code, write the smallest non-zero number which does not appear in the code at that position or to the right, and which has not already been written down in the new code. This gives the pair of sequences ( 4 5 7 9 0 6 ) 8 0 8 0 8 6 0 8 0 Now its easy to draw the tree. We could start by joining 0 to 8, then 8 to, then to then to, and so on. Don t forget to add the edge 0 to. 6 7 4 9 5 8 0 8
Question 8. [6] Find a minimum spanning tree in the weighted graph below using Kruskal s Algorithm starting with the shaded edge. Shade those edges which are in your minimum tree in the figure, and write down the total cost of your minimum tree. 7 Figure : A graph with edge costs Solution. At each stage, pick any edge of lowest cost which does not create a cycle with the edges chosen so far. There are many ways to do this, but in the end, when no more edges can be added without creating a cycle, we have a minimum cost tree (there are many minimum cost trees, but they all have the same minimum cost). Total cost of minimum tree 8 9
Question 9 [6] State and prove Euler s Formula. Solution. Bookwork 0
Question 0. [6] (a) Determine the generating series for the set of compositions of n into k parts where each part of the composition is an element of the set {0, }. Solution. The generating series for S = {(x, x,..., x k ) : x i {0, } i} is Φ S (x) = ( + x ) k. (b) Determine the number of compositions of n into k parts where each part of the composition is an element of the set {0, }. Solution. We have to find x n in Φ S (x). So we use the binomial theorem Φ S (x) = k j=0 ( ) k x j. j If n is odd, then this sum has no x n in it (since j is always even). We expected this: an odd number can t be written as a sum of 0s and s. Suppose now n is even. Then when j = n/ in the sum, we get x n. The answer is whatever is in front of x n, which, in this case, happens to be ( k n/) when n is even. So that is the answer when n is even, the answer is zero when n is odd.
Blank Page