404_Review

# 404_Review - UMass Lowell CS Fall 2001 Sample Review Questions Answers for 91.404 Material I Function Order of Growth(20 points 1(5 points Given

This preview shows pages 1–5. Sign up to view the full content.

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 43)

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

View Full Document
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 Explanation: f 1 = (nlgn) and nlgn = (n) implies that f 1 = (n) . f 1 = (n) and f 3 = Θ (n) imply that f 1 = ( f 3 ) . 4. (5 points) f 3 = Ο ( f 2 ) TRUE FALSE Explanation: Counter-example: f 2 = 1 (page 2 of 43) n n 2 n lg n f 1 f 2 1 f 3 f 4
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 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) Explanation : Use the Master Theorem with a=1, b=4, f(n) = n/2 n log 4 1 = n 0 = 1 Ratio test yields: f(n)/n = (n/2)/1 = n/2 This is case 3, so the solution is Θ (f(n)) = Θ (n/2) = Θ (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 closed-form solution for T(n) (a) Θ (n 2 lg n) (b) Θ (n lg 2 n) (c) Θ (n lg(lg n)) Explanation : Some ways to solve this: recursion tree, expand to build a summation, or induction. Recursion tree has Θ (lglgn) levels and a total of Θ (n) work is done at each level, for a total of Θ (n lg(lg n)). Induction Hypothesis: T(k) = k lglg k + k/2 Base Case: T(4) = 6 Inductive Step: T(k 2 ) = k T(k) + k 2 = k (k lglg k + k/2) + k 2 = k 2 lglg k + k 2 + k 2 /2 = k 2 ( lglg k + 1 ) + k 2 /2 = k 2 ( lglg k + lg2 ) + k 2 /2 = k 2 ( lg(2lg k)) + k 2 /2 = k 2 lglg k 2 + k 2 /2 (page 3 of 43) k

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

View Full Document
UMass Lowell CS Fall, 2001 Sample Review Questions & Answers for 91.404 Material III: PseudoCode Analysis (30 points) Here you’ll use the pseudocode below for two functions Mystery1 and Mystery3 .
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/13/2012 for the course CS 91.503 taught by Professor Staff during the Spring '11 term at UMass Lowell.

### Page1 / 43

404_Review - UMass Lowell CS Fall 2001 Sample Review Questions Answers for 91.404 Material I Function Order of Growth(20 points 1(5 points Given

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

View Full Document
Ask a homework question - tutors are online