MAT 243 Test 2 SOLUTIONS, FORM A

Similar documents
MAT 243 Test 2 SOLUTIONS, FORM A

Fall 2017 Test II review problems

Math 109 HW 9 Solutions

Topic Contents. Factoring Methods. Unit 3: Factoring Methods. Finding the square root of a number

Name CMSC203 Fall2008 Exam 2 Solution Key Show All Work!!! Page (16 points) Circle T if the corresponding statement is True or F if it is False.

Homework #2 Solutions Due: September 5, for all n N n 3 = n2 (n + 1) 2 4

Induction. Induction. Induction. Induction. Induction. Induction 2/22/2018

then the hard copy will not be correct whenever your instructor modifies the assignments.

Input Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary

Remainders. We learned how to multiply and divide in elementary

Student Responsibilities Week 8. Mat Section 3.6 Integers and Algorithms. Algorithm to Find gcd()

Mat Week 8. Week 8. gcd() Mat Bases. Integers & Computers. Linear Combos. Week 8. Induction Proofs. Fall 2013

Exercise on Continued Fractions

Fibonacci mod k. In this section, we examine the question of which terms of the Fibonacci sequence have a given divisor k.

The Euclidean Algorithm and Multiplicative Inverses

NOTE: You have 2 hours, please plan your time. Problems are not ordered by difficulty.

The running time of Euclid s algorithm

Mathematical Induction

MATH 25 CLASS 12 NOTES, OCT Contents 1. Simultaneous linear congruences 1 2. Simultaneous linear congruences 2

Math 230 Final Exam, Spring 2008

201-1A5-MT - Mathematics Summer 2015 HOMEWORK 2 Deadline : Sunday, August 30, 2015 at 12 :30.

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

Intermediate Math Circles February 29, 2012 Linear Diophantine Equations I

Chinese Remainder Theorem

There are seven questions, of varying point-value. Each question is worth the indicated number of points.

Mathematical Induction

NOTES ON SIMPLE NUMBER THEORY

2WF15 - Discrete Mathematics 2 - Part 1. Algorithmic Number Theory

Algorithms 2/6/2018. Algorithms. Enough Mathematical Appetizers! Algorithm Examples. Algorithms. Algorithm Examples. Algorithm Examples

The most factored form is usually accomplished by common factoring the expression. But, any type of factoring may come into play.

Discrete Mathematics CS October 17, 2006

Fall 2015 Lecture 14: Modular congruences. cse 311: foundations of computing

Discrete Mathematics: Logic. Discrete Mathematics: Lecture 14. Recursive algorithm

Definition: A "system" of equations is a set or collection of equations that you deal with all together at once.

Ch 4.2 Divisibility Properties

3 - Induction and Recursion

3 Finite continued fractions

Number Theory. Zachary Friggstad. Programming Club Meeting

Algebra for error control codes

CS 829 Polynomial systems: geometry and algorithms Lecture 3: Euclid, resultant and 2 2 systems Éric Schost

Divisibility in the Fibonacci Numbers. Stefan Erickson Colorado College January 27, 2006

Partial Fractions. June 27, In this section, we will learn to integrate another class of functions: the rational functions.

Solutions to Practice Final 3

CSCE 750, Spring 2001 Notes 1 Page 1 An outline of the book 1. Analyzing algorithms 2. Data abstraction 3. Recursion and induction 4. Sorting 5. Selec

Direct Proof MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Direct Proof Fall / 24

Math 3012 Applied Combinatorics Lecture 4

Chapter 5.1: Induction

Solutions to Math 41 First Exam October 15, 2013

Notes on Continued Fractions for Math 4400

Computational Complexity - Pseudocode and Recursions

Exercises Exercises. 2. Determine whether each of these integers is prime. a) 21. b) 29. c) 71. d) 97. e) 111. f) 143. a) 19. b) 27. c) 93.

Mathematical Induction. Part Two

Discrete Mathematics and Probability Theory Summer 2014 James Cook Note 5

Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Spring 2006

2301 Assignment 1 Due Friday 19th March, 2 pm

Mathematical Induction. Part Two

NUMBER THEORY AND CODES. Álvaro Pelayo WUSTL

Writing Assignment 2 Student Sample Questions

Typos/errors in Numerical Methods Using Matlab, 4th edition by Mathews and Fink

Algorithms (II) Yu Yu. Shanghai Jiaotong University

CS 161 Summer 2009 Homework #2 Sample Solutions

Applied Cryptography and Computer Security CSE 664 Spring 2017

Math 261 Exercise sheet 5

2.3 In modular arithmetic, all arithmetic operations are performed modulo some integer.

CPSC 467: Cryptography and Computer Security

Fermat s Little Theorem. Fermat s little theorem is a statement about primes that nearly characterizes them.

Discrete Math in Computer Science Solutions to Practice Problems for Midterm 2

Algorithms and Their Complexity

Grade 7/8 Math Circles. Continued Fractions

Algorithms CMSC Basic algorithms in Number Theory: Euclid s algorithm and multiplicative inverse

CS 4424 GCD, XGCD

PRIMALITY TESTING. Professor : Mr. Mohammad Amin Shokrollahi Assistant : Mahdi Cheraghchi. By TAHIRI JOUTI Kamal

6.4 Division of Polynomials. (Long Division and Synthetic Division)

CMPUT 403: Number Theory

5 + 9(10) + 3(100) + 0(1000) + 2(10000) =

Number Theory and the abc Conjecture

MAT 210 Test #1 Solutions, Form A

Problem Set 5 Solutions

Chapter 3: Root Finding. September 26, 2005

Chapter 3 Basic Number Theory

MATH 361: NUMBER THEORY FOURTH LECTURE

Chapter 5. Number Theory. 5.1 Base b representations

Proof Techniques (Review of Math 271)

2.2 Inverses and GCDs

Math 55 Second Midterm Exam, Prof. Srivastava April 5, 2016, 3:40pm 5:00pm, F295 Haas Auditorium.

Section 4.1: Sequences and Series

The Euclidean Algorithm

. As x gets really large, the last terms drops off and f(x) ½x

2. THE EUCLIDEAN ALGORITHM More ring essentials

Proofs. Methods of Proof Divisibility Floor and Ceiling Contradiction & Contrapositive Euclidean Algorithm. Reading (Epp s textbook)

O Notation (Big Oh) We want to give an upper bound on the amount of time it takes to solve a problem.

Math 110 FOUNDATIONS OF THE REAL NUMBER SYSTEM FOR ELEMENTARY AND MIDDLE SCHOOL TEACHERS

A p-adic Euclidean Algorithm

CS 360, Winter Morphology of Proof: An introduction to rigorous proof techniques

Integers and Division

Instructional Materials for the WCSD Math Common Finals

CSE 20 DISCRETE MATH. Fall

Solutions to MAT 117 Test #1

With Question/Answer Animations. Chapter 4

3. Algorithms. What matters? How fast do we solve the problem? How much computer resource do we need?

Transcription:

MAT 24 Test 2 SOLUTIONS, FORM A 1. [1 points] Prove the following using Mathematical Induction. L 2 i = L n L n+1 + 2 where L is the Lucas sequence: L 0 = 2 L 1 = 1 L n = L n 1 + L n 2, n 2 Solution: Let P (n) denote the predicate L 2 i = L n L n+1 + 2 (not just the right-hand side). First, P (0) is true, because the left-hand side is L 0 2 = 2 2 = 4 and the right-hand side is L 0 L 1 + 2 = 2 1 + 2 = 4. Now, assume that P (k) is true, that is The goal is to prove P (k + 1), which is This is true, because k+1 L 2 i = k L 2 i = L k L k+1 + 2. k+1 L 2 i = L k+1 L k+2 + 2. k L 2 i + L 2 k+1 = (L k L k+1 + 2) + L 2 k+1 = L k+1 (L k + L k+1 ) + 2 = L k+1 L k+2 + 2. Hence, by the Principle of Mathematical Induction, L 2 i = L n L n+1 + 2 is true for all n. Grading: + points for the base case, + points for setting up the inductive case, + points for proving the inductive case. 2. [10 points] Find a simple function g(x) such that the following function is O(g(x)). x ( 12 2 {{ x + 2 {{ 4 ) 2 x 4 x (8 x x + {{ 2 ) x 2 {{ x max( x, 2 x ) = x max(2 x, 4 x ) = 4 x 4 x x = 12 x + ( 4 + 2 (ln x) 2 ) ( 9 2 x + x ) 1 (ln x) 2 2 x x {{ max(1, (ln x) 2 ) = (ln x) 2 max(2 x, x ) = 2 x 2 x (ln x) 2 {{ max(12 x, 2 x (ln x) 2 ) = 12 x Solution: The big-o estimates for each piece of the formula above are given. The final answer is 12 x. Grading: Done on a 0///7/10 point basis. 2

MAT 24 Test 2 SOLUTIONS, FORM A. Evaluate the following. a. [ points] 6 mod 10 Solution: 6 divided by 10 gives a quotient of 6 and a remainder of. Thus 6 mod 10 =. b. [ points] 6 div 10 Solution: 6 divided by 10 gives a quotient of 6 and a remainder of. Thus 6 div 10 = 6. c. [ points] (67 div 9) mod (67 mod 9) Solution: 67 divided by 9 gives a quotient of 7 and a remainder of 4. Thus (67 div 9) mod (67 mod 9) = 7 mod 4 = because the remainder when you divide 7 by 4 is. 4. [10 points] Find real numbers C and k such that x + x 4 x + 8x 2 4x 7 C x whenever x k and show that they work. Solution: The easiest way to get an upper bound on x + x 4 x + 8x 2 4x 7 is to write x + x 4 x + 8x 2 4x 7 x + x 4 + x + 8x 2 + 4x + 7 Note the change in signs to + s! = x + x 4 + x + 8 x 2 + 4 x + 7 x 0 Now, if x 1, then x x n for all n <. In other words, you can replace all the x n terms with x : = x + x + x + 8 x + 4 x + 7 x = 28 x Thus, you can let C = 28 and k = 1. (The proof that they work is the scratch work above.) Other answers were possible. In that case, the scratch work was analyzed to make sure that the choice of C and k really did work. Grading: On a 0///7/10 point basis. Grading for common mistakes: 2 points for breaking up Y Z into Y Z.

MAT 24 Test 2 SOLUTIONS, FORM A. [10 points] Find a big-o estimate for the running time of the following pseudocode. s 0 t 1 i 1 do for j from n + n 2 to n + n s s t t s t end for i 2i until i 4n Solution: Start on the inside of the loops and work your way outwards. Inside of the for loop, there are two assignment statements (for s and t). Each of these takes time O(1), so the running time for one iteration of the for loop is O(max(1, 1)) = O(1). The number of iterations of the for loop is O(( n + n ) ( n + n 2 )) = O(n n 2 ) = O(n ). Hence, the running time for the for loop is O(1 n ) = O(n ). Now for the do loop; one iteration consists of the for loop (running time: O(n )) followed by an assignment statement (running time: O(1)). Hence the running time of one iteration of the do loop is O(max(n, 1)) = O(n ). Now you need to find the number of iterations of the do loop. Let k be the number of times the do loop is executed. The value of i after k iterations can be calculated by considering some small values and looking for a pattern: k i, after k loops 1 2 2 4 8 So it appears that i = 2 k after k loops. The equation which tells us how many iterations will occur is i = 4n, which becomes i = 4n (2 k ) = 4n 8 k = 4n k ln 8 = ln(8 k ) = ln(4n) = ln 4 + ln n k = ln 4 ln 8 + 1 ln n = O(ln n) ln 8 Thus, the running time for the do loop is O(ln n n ) = O(n ln n). Finally, there are three assignment statements before the loop, which all take time O(1). The overall running time is thus O(max(1, 1, 1, n ln n)) = O(n ln n). Grading: Done on a 0///7/10 point basis. 6. [10 points] Use the Euclidean Algorithm to find gcd(1892, 090). Solution: 1892 = 6 090 + 412 090 = 7 412 + 206 412 = 2 206 + 0 The gcd is the last nonzero remainder, so gcd(1892, 090) = 206. Grading for common mistakes: 7 points for no work, points for not using the Euclidean Algorithm. 4

7. [10 points] Convert 201 to base 9. MAT 24 Test 2 SOLUTIONS, FORM A Solution: Repeatedly divide quotients by 9: 201 = 22 9 + 8 22 = 24 9 + 7 24 = 2 9 + 6 2 = 0 9 + 2 Reading from bottom to top yields (2678) 9. Grading for common mistakes: 7 points for no work; 2 points for reading off the remainders backwards; 7 points for converting from base 9 to base 10. 8. Let S be the set defined as follows: (i) S. (ii) If x S, then x 2 S and x S. (iii) The only elements of S are those which can be obtained from condition (i) by applying condition (ii) a finite number of times. a. [10 points] Find S 0, S 1, and S 2. Solution: S n is the set of all elements of S which are obtained from the base case(s) by applying { the recursive part(s) exactly n times. Hence S 0 = is the set of base cases. Then { S 1 = 2, = S 2 = { 7 { 7, 9 7 2,, 9 2, 9 = { 17, 21, 1, 27 Grading: +2 points for S 0, +4 points for S 1, and +4 points for S 2. Grading for common mistakes: 2 points for including the base case(s) in S 1, including S 1 in S 2. b. [10 points] Use Structural Induction to prove that for all x S, x is a fraction whose numerator is odd and whose denominator is (when reduced to lowest terms). Solution: There are two parts to a structural induction proof: showing that the property is true for the base case(s), and showing that the property is preserved when the recursive rule(s) are applied. First the base case: is clearly an odd number divided by. Now, suppose x S, and that x is an odd number divided by ; i.e. x = n, where n is odd. Then: x 2 = n 2 = n 10 is an odd number divided by ; the numerator is odd, because it is the sum of an odd number and an even number. x = n = n is an odd number divided by ; the numerator is odd, because it is the product of two odd numbers. Hence, by Structural Induction, every element of S is an odd number divided by. Grading for common mistakes: points for only considering x = in the recursive part.

MAT 24 Test 2 SOLUTIONS, FORM B 1. [1 points] Prove the following using Mathematical Induction. F 2 i = F n F n+1 where F is the Fibonacci sequence: F 0 = 0 F 1 = 1 F n = F n 1 + F n 2, n 2 Solution: Let P (n) denote the predicate F 2 i = F n F n+1 (not just the right-hand side). First, P (0) is true, because the left-hand side is F 2 0 = 0 2 = 0 and the right-hand side is F 0 F 1 = 0 1 = 0. Now, assume that P (k) is true, that is The goal is to prove P (k + 1), which is This is true, because k+1 F 2 i = k F 2 i = F k F k+1. k+1 F 2 i = F k+1 F k+2. k F 2 i + F 2 k+1 = F k F k+1 + F 2 k+1 = F k+1 (F k + F k+1 ) = F k+1 F k+2. Hence, by the Principle of Mathematical Induction, F 2 i = F n F n+1 is true for all n. Grading: + points for the base case, + points for setting up the inductive case, + points for proving the inductive case. 2. [10 points] Find a simple function g(x) such that the following function is O(g(x)). 10 ( 9 2 x + x ) x + ( 9 + 2 (ln x) 2 4 {{ x! ) ( 8x ) 1 1 x x {{ x 1 (ln x) 2 x! 1 x max(1, x, x ) = x max(1, (ln x) 2 max(1, x) = x, x!) = x! 1 x x = 9 x x! x max(9 x, x! x) = x! x Solution: The big-o estimates for each piece of the formula above are given. The final answer is x! x. Grading: Done on a 0///7/10 point basis. 2

MAT 24 Test 2 SOLUTIONS, FORM B. Evaluate the following. a. [ points] 49 mod 6 Solution: 49 divided by 6 gives a quotient of 8 and a remainder of 1. Thus 49 mod 6 = 1. b. [ points] 49 div 6 Solution: 49 divided by 6 gives a quotient of 8 and a remainder of 1. Thus 49 mod 6 = 8. c. [ points] (1 div 8) mod (1 mod 8) Solution: 1 divided by 8 gives a quotient of 6 and a remainder of. Thus (1 div 8) mod (1 mod 8) = 6 mod = 0 because the remainder when you divide 6 by is zero. 4. [10 points] Find real numbers C and k such that x 6 4x 4 4x 2 8x + 7 C x 6 whenever x k and show that they work. Solution: The easiest way to get an upper bound on x 6 4x 4 4x 2 8x + 7 is to write x 6 4x 4 4x 2 8x + 7 x 6 + 4x 4 + 4x 2 + 8x + 7x 0 Note the change in signs to + s! = x 6 + 4 x 4 + 4 x 2 + 8 x + 7 x 0 Now, if x 1, then x 6 x n for all n < 6. In other words, you can replace all the x n terms with x 6 : = x 6 + 4 x 6 + 4 x 6 + 8 x 6 + 7 x 6 = 24 x 6 Thus, you can let C = 24 and k = 1. (The proof that they work is the scratch work above.) Other answers were possible. In that case, the scratch work was analyzed to make sure that the choice of C and k really did work. Grading: On a 0///7/10 point basis. Grading for common mistakes: 2 points for breaking up Y Z into Y Z.

MAT 24 Test 2 SOLUTIONS, FORM B. [10 points] Find a big-o estimate for the running time of the following pseudocode. s 0 t 0 for i from 2 n + n to n + 2 n j 0 while j 2 < n s 2s 4t s s + t j j + 4 end while if i 2 9s then s 2s n 2 end if end for Solution: Start on the inside of the loops and work your way outwards. When the if statement is executed, a condition is checked (which takes time O(1)), and if that statement is true, then an assignment statement is made (which takes time O(1)); thus, the overall running time of the if statement is O(max(1, 1)) = O(1). Now for the while loop. Every iteration of the while loop consists of three assignment statements, each of which takes time O(1), so each iteration takes time O(max(1, 1, 1)) = O(1). Now you need to calculate the number of iterations of the while loop. To do this, you need to consider the value of j after k iterations. Constructing a small table (shown below), it appears that j = 4k after k iterations. The equation which tells you how many iterations will actually occur is j 2 = n, which becomes k j, after k iterations 0 0 1 4 2 8 12 (4k) 2 = n 16k 2 = n k 2 = n 16 n k = 16 = 1 4 n/2 = O(n /2 ). Thus, the running time of the while loop is O(n /2 1) = O(n /2 ). Now for the for loop; one iteration of the for loop involves an assignment, the while loop, and the if statement. The total running time of one iteration is then O(max(1, n /2, 1)) = O(n /2 ). The number of iterations of the for loop is O(( n + 2 n ) (2 n + n)) = O( n n) = O( n ), and the total running time of the for loop is O(n /2 n ). Finally, two assignment statements are executed, in addition to the for loop. The overall running time is O(max(1, 1, n /2 n )) = O(n /2 n ). Grading: Done on a 0///7/10 point basis. 6. [10 points] Use the Euclidean Algorithm to find gcd(4189, 6860). Solution: 4189 = 6 6860 + 7 6860 = 9 7 + 24 7 = 24 + 0 The gcd is the last nonzero remainder, so gcd(4189, 6860) = 24. Grading for common mistakes: 7 points for no work, points for not using the Euclidean Algorithm. 4

7. [10 points] Convert 201 to base 6. MAT 24 Test 2 SOLUTIONS, FORM B Solution: Repeatedly divide quotients by 6: 201 = 6 + = 6 + = 9 6 + 1 9 = 1 6 + 1 = 0 6 + 1 Reading from bottom to top yields (11) 6. Grading for common mistakes: 7 points for no work; 2 points for reading off the remainders backwards; 7 points for converting from base 6 to base 10. 8. Let S be the set defined as follows: (i) 1 S. (ii) If x S, then x + 2 S and 7x S. (iii) The only elements of S are those which can be obtained from condition (i) by applying condition (ii) a finite number of times. a. [10 points] Find S 0, S 1, and S 2. Solution: S n is the set of all elements of S which are obtained from the base case(s) by applying { 1 the recursive part(s) exactly n times. Hence S 0 = is the set of base cases. Then { 1 S 1 = + 2, 1 { 7 7 = { 7 S 2 = + 2, 7 { 1 7 =, 49 Grading: +2 points for S 0, +4 points for S 1, and +4 points for S 2. Grading for common mistakes: 2 points for including the base case(s) in S 1, including S 1 in S 2. b. [10 points] Use Structural Induction to prove that for all x S, x is a fraction whose numerator is odd and whose denominator is (when reduced to lowest terms). Solution: There are two parts to a structural induction proof: showing that the property is true for the base case(s), and showing that the property is preserved when the recursive rule(s) are applied. 1 First the base case: is clearly an odd number divided by. Now, suppose x S, and that x is an odd number divided by ; i.e. x = n, where n is odd. Then: x + 2 = n + 2 = n + 6 is an odd number divided by ; the numerator is odd, because it is the sum of an odd number and an even number. 7x = 7 n = 7n is an odd number divided by ; the numerator is odd, because it is the product of two odd numbers. Hence, by Structural Induction, every element of S is an odd number divided by. Grading for common mistakes: points for only considering x = 1 in the recursive part.