404_review_no_answers

404_review_no_answers - UMass Lowell CS Fall, 2001 Sample...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
UMass Lowell CS Fall, 2001 Sample Review Questions & Answers for 91.404 Material (page 1 of 37 ) I : Function Order of Growth (20 points) 1 . (5 points) Given the following list of 3 functions: 3 (n ) 25 + ( 8 n ) (n lg n) - 6 2 Circle the one ordering below in which the 3 functions appear in increasing asymptotic growth order. That is, find the ordering f 1 , f , f , such that f = O(f 2 3 1 2 ) and f = O(f 2 3 ) . (a) 3 25 + ( 8 n ) (n lg n) - 6 2 (b) 25 + ( 8 n ) (n lg n) - 6 3 2 (c) (n lg n) - 6 3 (n ) 2 5 + ( 8 n ) 2 2. (5 points) Given the following list of 3 functions: ) + 5 9 (lg( lg n)) lg n (1/6)n! (2 Circle the one ordering below in which the 3 functions appear in increasing asymptotic growth order. That is, find the ordering f 1 , f , f , such that f = O(f 2 3 1 2 ) and f = O(f 2 3 ) . ) + 5 9 (lg( lg n)) lg n (a) (1/6)n! (2 (b) (2 ) + 5 9 (lg( lg n)) (1/6)n! lg n lg n (c) 9 (lg( lg n)) (2 ) + 5 (1/6)n!
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
UMass Lowell CS Fall, 2001 Sample Review Questions & Answers for 91.404 Material (page 2 of 37 ) For problems 3 and 4, assume that: f 1 = Ω (n lgn) f 2 = Ο ( n 2 ) f 3 = Θ (n) f 4 = Ω (1) For each statement: Circle TRUE if the statement is true. Circle FALSE if the statement is false. Circle only one choice. 3. (5 points) f 1 = Ω ( f 3 ) TRUE FALSE 4. (5 points) f 3 = Ο ( f 2 ) TRUE FALSE
Background image of page 2
UMass Lowell CS Fall, 2001 Sample Review Questions & Answers for 91.404 Material (page 3 of 37 ) II: Solving a Recurrence (10 points) In each of the 3 problems below, solve the recurrence by finding a closed-form function f(n) that represents a tight bound on the asymptotic running time of T(n) . That is, find f(n) such that T(n) = Θ (f(n)) . 1 . (5 points) Solve the recurrence : T(n) = T(n/4) + n/2 [You may assume that T(1) = 1 and that n is a power of 2.] Circle the one answer that gives a correct closed-form solution for T(n) (a) Θ (n) (b) Θ (n 2 ) (c) Θ (n lg n) 2 . (5 points) Solve the recurrence : T(n) = n T( n ) + n [You may assume that T(2) = 1 and that n is of the form 2 .] k Circle the one answer that gives a correct closed-form solution for T(n) (a) Θ (n 2 lg n) (b) Θ (n lg 2 n) (c) Θ (n lg(lg n))
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
UMass Lowell CS Fall, 2001 Sample Review Questions & Answers for 91.404 Material (page 4 of 37 ) III: PseudoCode Analysis (30 points) Here you’ll use the pseudocode below for two functions Mystery1 and Mystery3 . Mystery1 has three arguments: A : an array of integers; p, r : indices into A Mystery1 (A, p, r) Mystery3 (A, p, q, r) if p is equal to r initialize integer array B to be empty then return 0 q (p+r)/2 bb p g1 Mystery1(A, p, q) print "Mystery1 result1= ", g1 print contents of A[p]. .A[q] g2 Mystery1(A, q+1, r) print "Mystery1 result2= ", g2 print contents of A[q+1]. .A[r] g3 Mystery3(A, p, q, r) print "Mystery3 result= ", g3 print contents of A[p]. .A[r] return g3 pp p qq q+1 while pp <= q and qq <= r do if A[pp] <= A[qq] then B[bb] A[pp] pp pp + 1 bb bb + 1 else B[bb] A[qq] qq qq + 1 bb bb + 1 while qq <= r do B[bb] A[qq] qq qq + 1 bb bb + 1 while pp <= q do B[bb] A[pp] pp pp + 1 bb bb + 1 a 0 for i p to r do A[i] B[i] if i>p then d | A[i] - A[i-1] | if d > a then a d return a
Background image of page 4
UMass Lowell CS Fall, 2001 Sample Review Questions & Answers for 91.404 Material (page 5 of 37 ) (a) (10 points) For A = < 5,2,16,9,25 > , what output is generated by the call Mystery1(A, 1, 5) ?
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 37

404_review_no_answers - UMass Lowell CS Fall, 2001 Sample...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online