Exam 2 CMSC 203 Spring 2011: Mathematics Problems and Solutions, Exams of Discrete Structures and Graph Theory

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

2012/2013

Uploaded on 04/27/2013

ashakiran
ashakiran 🇮🇳

4.5

(27)

261 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Exam 2 CMSC 203 Spring 2011 Name SOLUTION KEY
Show All Work!
1. (16 points) Circle T if the corresponding statement is True or F if it is False.
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).
2. (8 points) Find the GCD and LCM of a = 2
4
5
8
7
3
11
1
17
6
and b = 2
3
5
4
11
2
13
2
17
2
19
2
ab = 2
4+3
5
8+4
7
3+0
11
1+2
13
0+2
17
6+2
19
0+2
so GCD(a,b) = 2
3
5
4
7
0
11
1
13
0
17
2
19
0
= 2
3
5
4
11
1
17
2
and LCM(a,b) = 2
4
5
8
7
3
11
2
13
2
17
6
19
2
.
3. (8 points) List out the search intervals of the Binary Search algorithm to find 6 in the list:
3 4 6 9 13 18 21 34 55 72 83 85 92 104 111 133
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}
Docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Exam 2 CMSC 203 Spring 2011: Mathematics Problems and Solutions and more Exams Discrete Structures and Graph Theory in PDF only on Docsity!

Show All Work!

  1. (16 points) Circle T if the corresponding statement is True or F if it is False.

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 ab 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).

  1. (8 points) Find the GCD and LCM of a = 2^45873111176 and b = 2^354112132172192

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.

  1. (8 points) List out the search intervals of the Binary Search algorithm to find 6 in the list: 3 4 6 9 13 18 21 34 55 72 83 85 92 104 111 133

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!

  1. (10 points) Find a numeric expression for.
  1. (12 points) Trace the Division Algorithm below to find (52 MOD 6).

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.

  1. (8 points) Give a Recursive Definition for the set S = { nN | n ≡ 3 MOD 7}:

Basis: 3 ∈ S

Induction: If n ∈ S, then ( n + 7) ∈ S.

  1. (8 points) Show n^19 is the Big-Oh of the algorithm with complexity:

(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

i = 0

10

i

i = 0

10

10 11( ) 2

----------------- 57

10 + (^1) Ð 1 7 Ð 1

  • ------------------------- 220 5 7 ( 11 Ð 1 ) 6 +--------------------------

Show All Work!

  1. (10 points) Prove ONE of the TWO Theorems below:

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!

  1. (10 points) Prove ONE of the TWO Theorems below by Contradiction or Contraposition.

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