Exercise #2 with solutions

Exercise #2 with solutions - large prime number Solution To...

This preview shows page 1. Sign up to view the full content.

1. Fibonacci numbers and golden ratio: F(19) = 4181, what is F(20)? Solution: F(20) / F(19) = 1.61803 => F(20) = 6765 2. What is an exponential algorithm? (Avoid circular definition, such as using the word exponential) Solution: an algorithm that the number of operations is a power of the size of the problem 3. Given the Full O n , find Partial O n and Big-O Algorithm Full O n Partial O n Big-O 1 340n 6 + 2n 4 + 4n +5000 2 5nlog(n) + 0.04n! 3 7(n-1) 2 + (5n 2 +8) Solution: Algorithm Full O n Partial O n Big-O 1 340n 6 + 2n 4 + 4n +5000 340n 6 n 6 2 5nlog(n) + 0.04n! 0.04n! n! 3 7(n-1) 2 + (5n 2 +8) 12n 2 n 2 4. Consider the following pseudocode which manages and reallocates memory usage by a program based on the size of a file which that program manages: As the file size n increases, memory will be consumed at what rate? (Perform Big-O analysis) Solution: O(2 n ) 5. Prove modular addition 6. Why does hash function require a
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: large prime number? Solution: To reduce the chance of collision 7. Define a hash function for your 9-digit student number, under following conditions: a. consider your student number as three 3-digit numbers b. use a prime number greater than 100, for example, 101 8. Given two prime numbers, 23 and 31. Find public and private key 9. You were given two algorithms to compute a b mod N for large values of a, b, N a. Which algorithm is faster? Why? b. Which algorithm breaks first as N increases in size? Why? while (file still open) let n = size of file for every 100,000 kilobytes of increase in file size double the amount of memory reserved modexp1(a,b,N) set ans=1 for i=1 . . . b ans=ans*a mod N return ans modexp2(a,b,N) if b=0 return 1 ans=modexp2(a, floor(b/2), N) if b is even return ans 2 mod N else return a * ans 2 mod N...
View Full Document

This note was uploaded on 03/31/2012 for the course MIE 335 taught by Professor Frances during the Spring '12 term at University of Toronto.

Ask a homework question - tutors are online