MAT Test SOLUTIONS, FORM A 1. [10 points] Give a recursive definition for the set of all ordered pairs of integers (x, y) such that x < y. Solution: Let S be the set described above. Note that if (x, y) S, then there are five neighboring ordered pairs which are also in S: (x + 1, y + 1), (x, y + 1), (x 1, y + 1), (x 1, y), and (x 1, y 1). (If (x, y) = (0, 1), then (x, y 1), (x + 1, y 1) and (x + 1, y) are not in S.) This gives you the recursive part. The next step is to determine which elements of S cannot be obtained from another element in S using the rules above; (0, 1) is one such ordered pair (although there are others). Every ordered pair in S can be reached from (0, 1) by the recursive part, so a description for S is: (1) (0, 1) S. () If (x, y) S, then (x + 1, y + 1), (x, y + 1), (x 1, y + 1), (x 1, y), (x 1, y 1) S. () Finiteness: Every element of S is obtained by applying () a finite number of times. Note that (0, 1) can be replaced with (a, a + 1) for any integer a, and that part () must include (x+1, y+1) and (x 1, y 1) and at least one of the other three points, so other answers were possible. Grading: + points (each) for conditions (1) and (), + points for condition (). Grading for partial credit: + points (total) for not giving a set of ordered pairs.. [10 points] Convert () 10 to base 6. Solution: Repeatedly divide by 6, repeating with the remainder, until the quotient is zero: = 0 6 + 0 = 6 6 + 6 = 1 6 + 0 1 = 0 6 + 1 Now take the remainders in reverse order, to get (10) 6. Grading: +7 points for the repeated division, + points for putting the remainders together.. [10 points] Convert (1000111000111111) to base. Solution: The easiest way to do this is to break up the number into groups of two (since = ), starting from the right, then convert each digit to base : ( 10 00 0 11 10 00 0 11 11 11 so the answer is (00). Grading: +5 points for splitting up the binary number, +5 points for converting each digit. )
MAT Test SOLUTIONS, FORM A. [10 points] Find a function g(x) such that (n 5 + log(5 n ))( n + n ) is O(g(n)) and g(x) is as simple and small as possible. Solution: In the first factor, n 5 grows faster than log(5 n ) = n log 5, so the first factor is O(n 5 ). In the second factor, n grows faster than n, so the second factor is O( n ). The product will grow as the product of these two functions, or O(n 5 n ). ) (n 5 + log(5 n ))( + n } n 5 {{ n } n 5 n Grading: Done on a 0 5 7 10-point basis. Grading for common mistakes points for forgetting to multiply n 5 by n ; points for leaving a constant in the answer. 5. [15 points] Use mathematical induction to show that for n 0. Solution: Let P (n) be the predicate n k k = + [n ] n n k k = + [n ] n. To prove P (n) for all n 0, you need to prove two things: First, P (0) is true, because the two sides of the equation are Now, assume that P (m) is true; that is, 0 k k = 0 + [ 0 ] 0 = 0 m k k = + [m ] m. The goal is to prove P (m + 1), which is (m+1) k k = + [(m + 1) ] (m+1). This is done by manipulating the sum, and using the assumption that P (m) is true: m+1 k k = m k k + (m + 1) m+1 = + (m ) m + (m + 1) m+1 = + (m 1) m+1 + (m + 1) m+1 = + (m) m+1 = + [(m + 1) ] m+1. Hence, P (m) does imply P (m + 1). By the principle of mathematical induction, P (n) is true for all nonnegative integers n. Grading: +5 points for checking the initial case, +5 points for setting up the inductive argument, +5 points for doing the algebra.
6. Let m = 151 and n = 9. MAT Test SOLUTIONS, FORM A a. [10 points] Use the Euclidean Algorithm to find gcd(m, n). Solution: Use repeated division: 9 = 151 + 51 151 = 51 + 117 51 = 117 + 0 The GCD is the last nonzero remainder, which is 117. Graded on a 0 5 7 10-point basis. Grading for common mistakes: +5 points (total) for finding the prime factorization. b. [10 points] Find the Bézout coefficients for m and n; that is, find integers a and b such that am + bn = gcd(m, n). Solution: This builds on your answer to part (a), so fortunately most people got that right. Start off by taking the second equation and solving for 117: 117 = 151 51 Now take the first equation and solve it for 51, and then substitutate that into the equation right above this text. Thus the coefficients are 9 and. = 151 (9 151) = 9 151 9 Grading: + points for solving each equation, and + points for substitution.
MAT Test SOLUTIONS, FORM A 7. [15 points] Evaluate the following quantities. a. mod 7 Answer:. b. mod 7 Answer: 5. ( = 7 + 5.) c. (0 mod 1) div (11 mod 6) Solution: This is 7 div 5 = 1. Grading for common mistakes: points for bad division (non-integer answers, etc.) 8. [10 points] Let S be the set of strings defined recursively by (1) λ S; () If x S, then 1x S and x0 S; () Only these strings are in S. Use structural induction to prove that S does not contain any string x in which a 0 occurs to the left of a 1 in x. (Hence, for instance, 01110 S.) Solution: A full solution looks like something along these lines: Suppose that x S. If x = λ, then x does not contain a 0 to the left of a 1, because x has no characters. If x = 1y, where y S, then we may assume that y does not contain a 0 to the left of a 1. Now x cannot contain a 0 to the left of a 1, because that 0 would have to be part of the string y, as well as the 1 which is to the right of that 0. Hence, in this case, x does not contain a 0 to the left of a 1. If x = y0, where y S, then we may assume that y does not contain a 0 to the left of a 1. The string x cannot contain a 0 to the left of a 1, because the 1 would have to be part of the string y, as well as the 0 to the left of that 1. Hence, in this case, x does not contain bad, either. Hence, by induction, no element of S contains a 0 to the left of a 1. Grading: + points for the base case, + points for each induction case, + points for the final sentence. Grading for common mistakes: +5 points (total) if several examples were done. 5
MAT Test SOLUTIONS, FORM B 1. [10 points] Give a recursive definition for the set of all ordered pairs of integers (x, y) such that x y. Solution: Let S be the set described above. Note that if (x, y) S, then there are five neighboring ordered pairs which are also in S: (x + 1, y + 1), (x + 1, y), (x + 1, y 1), (x, y 1), and (x 1, y 1). (If (x, y) = (0, 0), then (x 1, y), (x 1, y + 1) and (x, y + 1) are not in S.) This gives you the recursive part. The next step is to determine which elements of S cannot be obtained from another element in S using the rules above; (0, 0) is one such ordered pair (although there are others). Every ordered pair in S can be reached from (0, 0) by the recursive part, so a description for S is: (1) (0, 0) S. () If (x, y) S, then (x + 1, y + 1), (x + 1, y), (x + 1, y 1), (x, y 1), (x 1, y 1) S. () Finiteness: Every element of S is obtained by applying () a finite number of times. Note that (0, 0) can be replaced with (a, a) for any integer a, and that part () must include (x+1, y+1) and (x 1, y 1) and at least one of the other three points, so other answers were possible. Grading: + points (each) for conditions (1) and (), + points for condition (). Grading for partial credit: + points (total) for not giving a set of ordered pairs.. [10 points] Convert () 10 to base 7. Solution: Repeatedly divide by 7, repeating with the remainder, until the quotient is zero: = 7 + 5 = 7 + 6 = 0 7 + Now take the remainders in reverse order, to get (65) 7. Grading: +7 points for the repeated division, + points for putting the remainders together.. [10 points] Convert (1100110000110001) to base 8. Solution: The easiest way to do this is to break up the number into groups of three (since = 8), starting from the right, then convert each digit to base 8: ( 1 1 100 110 6 000 0 110 6 001 1 so the answer is (16061) 8. Grading: +5 points for splitting up the binary number, +5 points for converting each digit. )
MAT Test SOLUTIONS, FORM B. [10 points] Find a function g(x) such that (n + log(n + 1))(n! + n ) is O(g(n)) and g(x) is as simple and small as possible. Solution: In the first factor, n grows faster than log(n + 1), so the first factor is O(n ). In the second factor, n! grows faster than n, so the second factor is O(n!). The product will grow as the product of these two functions, or O(n n!). (n + log(n + 1) )(n! + n ) n n! n n! Grading: Done on a 0 5 7 10-point basis. Grading for common mistakes: points for forgetting to multiply n by n!; points for leaving a constant in the answer. 5. [15 points] Use mathematical induction to show that n k k = [ n + ] n for n 0. Solution: Let P (n) be the predicate n k k = + [ n you need to prove two things: First, P (0) is true, because the two sides of the equation are 0 k k = 0 [ 0 + ] 0 = 0 Now, assume that P (m) is true; that is, m k k = [ m + ] m. The goal is to prove P (m + 1), which is (m+1) k k = + [ (m + 1) ] n. To prove P (n) for all n 0, ] (m+1). This is done by manipulating the sum, and using the assumption that P (m) is true: m+1 m k k = k k + (m + 1) m+1 = [ m + ] m + (m + 1) m+1 = [ m + 1 ] m+1 + (m + 1) m+1 = [ m + + ] m+1 = [ m + + + ] m+1 = [ (m + 1) + ] m+1. Hence, P (m) does imply P (m + 1). By the principle of mathematical induction, P (n) is true for all nonnegative integers n. Grading: +5 points for checking the initial case, +5 points for setting up the inductive argument, +5 points for doing the algebra.
6. Let m = 1 and n = 105. MAT Test SOLUTIONS, FORM B a. [10 points] Use the Euclidean Algorithm to find gcd(m, n). Solution: Use repeated division: 105 = 1 + 71 1 = 71 + 57 71 = 57 + 0 The GCD is the last nonzero remainder, which is 57. Graded on a 0 5 7 10-point basis. Grading for common mistakes: +5 points (total) for finding the prime factorization. b. [10 points] Find the Bézout coefficients for m and n; that is, find integers a and b such that am + bn = gcd(m, n). Solution: This builds on your answer to part (a), so fortunately most people got that right. Start off by taking the second equation and solving for 57: 57 = 1 71 Now take the first equation and solve it for 71, and then substitutate that into the equation right above this text. Thus the coefficients are 1 and. = 1 (105 1) = 1 1 105 Grading: + points for solving each equation, and + points for substitution.
MAT Test SOLUTIONS, FORM B 7. [15 points] Evaluate the following quantities. a. 5 mod Answer: 1 b. 5 mod Answer:. ( 5 = 7 +.) c. ( mod 1) div (17 mod 6) Solution: This equals 11 div 5 =. Grading for common mistakes: points for bad division (non-integer answers, etc.) 8. [10 points] Let S be the set of strings defined recursively by (1) λ S; () If x S, then 0x S and x1 S; () Only these strings are in S. Use structural induction to prove that S does not contain any string x in which a 0 occurs to the right of a 1 in x. (Hence, for instance, 01110 S.) Solution: A full solution looks like something along these lines: Suppose that x S. If x = λ, then x does not contain a 0 to the right of a 1, because x has no characters. If x = 0y, where y S, then we may assume that y does not contain a 0 to the right of a 1. Now x cannot contain a 0 to the right of a 1, because that 1 would have to be part of the string y, as well as the 0 which is to the right of that 1. Hence, in this case, x does not contain a 0 to the right of a 1. If x = y1, where y S, then we may assume that y does not contain a 0 to the right of a 1. The string x cannot contain a 0 to the right of a 1, because the 0 would have to be part of the string y, as well as the 1 to the left of that 0. Hence, in this case, x does not contain bad, either. Hence, by induction, no element of S contains a 0 to the right of a 1. Grading: + points for the base case, + points for each induction case, + points for the final sentence. Grading for common mistakes: +5 points (total) if several examples were done. 5