1. Suppose we have hardware capable of executing 106 instructions per second. How long would it take to execute an algorithm whose complexity function was: T(n) = 2N2 on an input size of n= 108? 2. An algorithm takes 0.5 ms for input size 100. How long will it take for input size500 if the running time is the following (assume low-order terms are negligible)? a. linear b. O(N logN) c. quadratic d. cubic Answer: a) 2.5 ms b) 3.37 ms c) 12.5 ms d) 62.5 ms Explanation: Determine how long it takes for an input size of 500 a) Linear For an input size of 500 time taken = ( ( 0.5 / 100 )* 500 ) ms = 2.5 ms b) 0(N log N ) First step : determine number of instructions For an input size ( N ) = 100 Log N = 6.65 ∴ N log N = 665 instructions i.e. 665 instructions is passed during 0.5ms For N log N = 500 N500 = 4483 instructions time taken = (4483 * 0.5)/665 = 3.37 ms. c) Quadratic lets take N = 100 N^2 = 10000 steps per 0.5 ms For N = 500 N^2 = 250,000 steps time taken = (25000*0.5) / 10000 = 12.5 ms d) cubic . lets take N = 100 N^3 = 1,000,000 steps per 0.5 ms hence for N = 500 N^3 = 125*10^6 steps hence time taken = ( (125*10^6)*0.5 / 10^6) = 62.5 ms 3. An algorithm takes 0.5 ms for input size 100. How large a problem can be solved in 1 min if the running time is the following (assume low-order terms are negligible)? a. linear b. O(N logN) c. Quadratic d. Cubic 4. Order the following functions by growth rate: N,√N, N1.5, N2, N logN, N log logN, N log2 N, N log(N2), 2/N, 2N, 2N/2, 37, N2 logN, N3. Indicate which functions grow at the same rate. 5. Prove that for any constant k, logk N = o(N). 6. Suppose T1(N) = O(f (N)) and T2(N) = O(f (N)). Which of the following are true? a. T1(N) + T2(N) = O(f (N)) b. T1(N) − T2(N) = o(f (N)) c. T1(N)/T2(N) = O(1) d. T1(N) = O(T2(N)) 7. For each of the following six program fragments: a. Give an analysis of the running time (Big-Oh will do). b. Implement the code in the language of your choice, and give the running time several values of N. c. Compare your analysis with the actual running times. for