This preview shows pages 1–5. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: UMass Lowell CS Fall, 2001 Sample Review Questions & Answers for 91.404 Material I : Function Order of Growth (20 points) 1 . (5 points) Given the following list of 3 functions: 3 (n 2 ) 25 + ( 8 n ) (n lg n)  6 Circle the one ordering below in which the 3 functions appear in increasing asymptotic growth order. That is, find the ordering f 1 , f 2 , f 3 , such that f 1 = O(f 2 ) and f 2 = O(f 3 ) . (a) 3 (n 2 ) 25 + ( 8 n ) (n lg n)  6 (b) 25 + ( 8 n ) (n lg n)  6 3 (n 2 ) (c) (n lg n)  6 3 (n 2 ) 25 + ( 8 n ) 2. (5 points) Given the following list of 3 functions: (1/6)n! (2 lg n ) + 5 9 (lg( lg n)) Circle the one ordering below in which the 3 functions appear in increasing asymptotic growth order. That is, find the ordering f 1 , f 2 , f 3 , such that f 1 = O(f 2 ) and f 2 = O(f 3 ) . (a) (1/6)n! (2 lg n ) + 5 9 (lg( lg n)) (b) (2 lg n ) + 5 9 (lg( lg n)) (1/6)n! (c) 9 (lg( lg n)) (2 lg n ) + 5 (1/6)n! (page 1 of 37) UMass Lowell CS Fall, 2001 Sample Review Questions & Answers for 91.404 Material 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 (page 2 of 37) UMass Lowell CS Fall, 2001 Sample Review Questions & Answers for 91.404 Material II: Solving a Recurrence (10 points) In each of the 3 problems below, solve the recurrence by finding a closedform 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 closedform 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 2 .] Circle the one answer that gives a correct closedform solution for T(n) (a) (n 2 lg n) (b) (n lg 2 n) (c) (n lg(lg n)) (page 3 of 37) k UMass Lowell CS Fall, 2001 Sample Review Questions & Answers for 91.404 Material III: PseudoCode Analysis (30 points) Here youll 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) if p is equal to r then return 0 q (p+r)/2 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 Mystery3 (A, p, q, r) initialize integer array B to be empty bb p 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...
View
Full
Document
This note was uploaded on 02/13/2012 for the course CS 91.404 taught by Professor Dr.karendaniels during the Fall '09 term at UMass Lowell.
 Fall '09
 DR.KARENDANIELS

Click to edit the document details