{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Midterm5Solutions

Midterm5Solutions - UMass Lowell CS 91.503 Fall 2001 Name...

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

UMass Lowell CS 91.503 Fall, 2001 Name: ___________________________ MIDTERM EXAM + SOLUTIONS This exam is open: - books - notes and closed : - neighbors - calculators The upper bound on exam time is 3 hours. Please write your name at the top of each page. Please put all your work on the exam paper. (Partial credit will only be given if your work is shown.) Good luck! (page 1 of 17)

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

View Full Document
UMass Lowell CS 91.503 Fall, 2001 Name: ___________________________ PART I 91.404 Review (27 points) 1. (9 points) Function Order of Growth Given: 1) f 1 (n) is in (n lg(lgn)) 2) f 2 (n) is in Ο (4 lgn ) 3) f 2 (n) is in Θ (f 3 (n)) 4) f 3 (n) is in (n lg 2 n) (a) (3 points) Can we conclude from statements (1)-(4) that f 3 (n) must be in Ο (n 2 ) ? Why or why not? Solution: YES . f 2 (n) is in Θ ( f 3 (n)) -> f 3 (n) is in Ο ( f 2 (n)) This, combined with f 2 (n) is in Ο (4 lgn ) implies (via transitivity) that f 3 (n) is in Ο (4 lgn ) . Now, observe that 4 lgn = 2 2lgn = 2 lg 2 n = n 2 . Thus, f 3 (n) is in Ο (n 2 ) . (b) (3 points) Can we conclude from statements (1)-(4) that f 1 (n) must be in ((2/5) n ) ? Why or why not? Solution: YES . f 1 (n) is in (n lg(lgn)) implies f 1 (n) is in (g(n)) for all g(n) smaller than nlg(lgn) . Now, observe that n lg(lgn)) is in ((2/5) n ) since ((2/5) n ) is <=1 for all positive n. This, combined with f 1 (n) is in (n lg(lgn)) implies (via transitivity) that f 1 (n) is in ((2/5) n ) . (c) (3 points) Can we conclude from statements (1)-(4) that f 1 (n) must be in Ο (n lgn) ? Why or why not? Solution: NO . f 1 (n) is in (n lg(lgn)) only provides a lower bound on f 1 (n) . n lgn is in (n lg(lgn)). It is possible for f 1 (n) to be larger than n lgn ; for example, f 1 (n) = n 2 . In this case, f 1 (n) is not in Ο (n lgn) . (page 2 of 17) (2/5) n 4 lgn = n 2 n lg 2 n f 3 f 2 n lg(lgn) f 1
UMass Lowell CS 91.503 Fall, 2001 Name: ___________________________ 2. (9 points) Recurrence In this problem, you will find a closed-form solution for the following recurrence: T(n) = T(n/4) + Θ (n) That is, you will find f(n) such that T(n) is in Θ (f(n)) . You may assume that: - n = 4 k for some positive integer k - T(1) = 1 (a) (3 points) Solve the recurrence using the Master Theorem. Solution: The recurrence is of the form T(n) = aT(n/b) + f(n) with a=1, b=4, and f(n)= Θ (n). Ratio test yields: This is case 3, so the solution is T(n) = f(n) = Θ (n). (page 3 of 17) ) ( 1 ) ( ) ( ) ( 1 log log 4 n n n n n n f a b Θ = Θ = Θ =

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

View Full Document
UMass Lowell CS 91.503 Fall, 2001 Name: ___________________________ (b) (6 points) Solve the recurrence by building a recursion tree and finding a closed-form solution of the resulting summation. i n i n i i n i i n n n = = = Θ = Θ = Θ 4 4 4 log 0 log 0 log 0 4 1 ) ( 4 1 ) ( 4 - - Θ = - - Θ = + 4 3 4 4 4 1 4 1 ) ( 1 4 1 1 4 1 ) ( 4 4 log 1 log n n n n - Θ = - Θ = - Θ = + - Θ = n n n n n n n n 1 4 ) ( 4 1 4 ) ( 4 1 4 ) ( 3 4 4 1 ) ( 4 4 4 log log log now, since 1 1 0 < n
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}