



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The solutions to exam 2 of the cmsc 203 course offered in spring 2011. The exam covers various mathematical concepts such as gcd, lcm, binary search, recursive algorithms, and mathematical induction. Students are encouraged to check their answers against this document.
Typology: Exams
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Show All Work!
T F GCD(10, 0) = 0.
T F If a prime divides the square of a Natural number, then it divides the number.
T F If a ≡ b MOD 5, then 5 divides both a and b.
T F Recursive algorithms generally use memory more efficiently than their equivalent Iterative version.
T F 1 + 2 + 3 + 4 + ... + 1000 = 500(1001).
T F Algorithms with O( n^2 ) are less efficient than those with O(2 n ).
T F The two Principles of Mathematical Induction are logically equivalent.
T F GCD(1000, 678) = GCD(678, 322).
ab = 24+3 5 8+4 7 3+0 11 1+2 13 0+2 17 6+2 19 0+ so GCD( a,b ) = 2^35470111130172190 = 2^354111172 and LCM( a,b ) = 2^45873112132176192.
Pass 1: {3, 4, 6, 9, 13, 18, 21, 34} and {55, 72, 83, 85, 92, 104, 111, 133}
Pass 2: {3, 4, 6, 9} and {13, 18, 21, 34}
Pass 3: {3, 4} and {6, 9}
Pass 4: {6} and {9}
Show All Work!
PROCEDURE MOD(A,B: integers) WHILE (A > B) A = A − B ENDWHILE OUTPUT (A)
Step 0 1 2 3 4 5 6 7 8 A 52 46 40 34 28 22 16 10 4 B 6 6 6 6 6 6 6 6 6 (A > B)? 1 1 1 1 1 1 1 1 0 OUTPUT 4.
Basis: 3 ∈ S
Induction: If n ∈ S, then ( n + 7) ∈ S.
(12 n^4 + 3 n^3 log^3 n )(3 n^7 + 4 n^3 )( n^6 + 5 n^2 + 4).
(12 n^4 + 3 n^3 log^3 n )(3 n^7 + 4 n^3 )( n^6 + 5 n^2 + 4) < (12 n^4 + 3 n^3 n^3 )(3 n^7 + 4 n^7 )( n^6 + 5 n^6 + 4 n^6 )
< (12 n^6 + 3 n^6 )(7 n^7 )(10 n^6 ) = (15 n^6 )(7 n^7 )(10 n^6 ) = 1050 n^19 which is O( n^19 ).
4 i +5 7 ( i ) i = 0
10
4 i +5 7 ( i ) i = 0
10
i = 0
10
i
i = 0
10
10 11( ) 2
----------------- 57
10 + (^1) Ð 1 7 Ð 1
Show All Work!
Theorem 1: For all Integers, n, if n is odd, then n^2 ≡ 1 MOD 8. (Hint: If an Integer is odd, then its successor is even.)
Theorem 2: Between any two distinct Real Numbers is another Real Number.
Theorem 1:
Proof: Let n be an odd Integer, so n = 2 k + 1, for some Integer k. We want to show
n^2 ≡ 1 MOD 8; that is ( n^2 − 1) = 8 p , for some Integer p.
Now, ( n^2 − 1) = (2 k + 1)^2 − 1 = (4 k^2 + 4 k + 1) − 1 = 4 k^2 + 4 k = 4 k ( k + 1). However, since k is an odd Integer, we see that ( k + 1), the successor of k , is even. This lets us assert that ( k + 1) = 2 m , for some Integer m.
Combining all this, we see that ( n^2 − 1) = 4 k ( k + 1) = 4 k (2 m ) = 8 km. Moreover, since k and m are
Integers, we conclude that p = km is an Integer, thus ( n^2 − 1) = 8 p , for some Integer p.
Therefore n^2 ≡ 1 MOD 8 for any odd Integer n. QED
Theorem 2:
Proof: Let X and Y be distince Real Numbers and, without loss of generality, assume X < Y.
Now, X = (2X) / 2 = (X + X) / 2 < (X + Y) / 2 < (Y + Y) / 2 = (2Y) / 2 = Y. Moreover, since X and Y are Real, we see that (X + Y) is Real, hence [ (X + Y) / 2 ] is Real. Since X < (X + Y) / 2 < Y, we conclude, therefore, that there exists a Real Number between distinct Real Numbers. QED
Show All Work!
Theorem 1: The set of Prime Numbers is infinite.
Theorem 2: For all Integers, n > 2, if n is prime, then n ≡ 1 MOD 2.
Theorem 1: Proof: (Contradiction) Assume the set of Prime Numbers is finite. Denote the finite set of the Primes as { p 1 , p 2 , p 3 , ... , pn } for some Natural Number n.
Now, construct the Natural Number, M = [ p 1 ( p 2 )( p 3 )( ... )( pn )] + 1. Since M is a Natural, it has a
prime factor, but since any prime number is also a factor of the product [ p 1 ( p 2 )( p 3 )( ... )( pn )], we
conclude that this prime factor must also divide 1. However this is a contradiction since no primes divide 1.
Therefore, the set of Primes is infinite. QED
Theorem 2: Proof: (Contraposition) We shall show for any Integer n > 2, if n ≡ 0 MOD 2, then n is composite.
Now, let n ≡ 0 MOD 2, for any Integer n > 2. This means that 2 divides ( n − 0) = n , hence n /2 is an Integer. Moreover, since n > 2, we see that n /2 > 1, thus n /2 = m for some Integer m. Consequently, n = 2 m with m > 1, hence n is composite.
Therefore, for all Integers, n > 2, if n is prime, then n ≡ 1 MOD 2. QED