{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

404_Review - UMass Lowell CS Fall 2001 Sample Review...

Info icon This preview shows pages 1–5. 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 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)
Image of page 1

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

View Full Document Right Arrow Icon
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
Image of page 2
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
Image of page 3

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

View Full Document Right Arrow Icon
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 .
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern