503MidtermExamSolF08

# 503MidtermExamSolF08 - UML CS 91.503 Midterm Exam Fall 2008...

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

UML CS 91.503 Midterm Exam Fall, 2008 1 of 10 MIDTERM EXAM SOLUTIONS Stats : to be determined later (with ?? points added) - Minimum: - Maximum: - Average: - Standard Deviation: 1: (5 points) Asymptotic Growth of Functions (a) (1 point) List the 4 functions below in nondecreasing asymptotic order of growth: () ( )( ) 2 3 lg 3 lg lg 32 lg n n n n n n n 1) n n 3 2) 2 lg n n 3) n n lg lg 3 4) 32 lg n smallest largest Rationale : 0 3 lim = n n n , so ( ) n n 3 is the smallest. ( ) ) lg lg ( lg lg 3 2 2 2 n n O n n n n = because ) lg lg ( lg 2 n n O n . ( ) n n 5 32 lg = ; this exponential function dominates the other 3 functions. ( ) n n n f n n O n f n n f n n f Ω Ω Θ 3 ) ( 4) ) ) lg (( ) ( 3) ) ( ) ( 2) ) ( ) ( ) 1 4 2 3 3 2 2 1 ( ) 32 lg n n n lg lg 3 3 n ( ) 2 lg n n 2 n ( ) n n 3 f 1 ( n ) f 2 ( n ) f 3 ( n ) f 4 ( n )

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

View Full Document
UML CS 91.503 Midterm Exam Fall, 2008 2 of 10 b) (1 point) )) ( ( ) ( 2 1 n f n f Ο TRUE FALSE Proof : ) ( ) ( ) ( ) ( 2 1 2 1 n O n f n n f Θ [1] by the definition of the Θ operator. ) ( 3 2 n O n [2]. Applying transitivity to [1] and [2] yields ) ( ) ( 3 1 n O n f [3]. Now, via transpose symmetry from ) ( ) ( 3 2 n n f Ω we have )) ( ( 2 3 n f O n [4]. Applying transitivity to [3] and [4] yields )) ( ( ) ( 2 1 n f n f Ο . c) (1 point) )) ( ( ) ( 4 3 n f n f Ω TRUE FALSE Counter-example : n n f = ) ( 3 and 3 4 ) ( n n f = . d) (1 point) ) ( ) ( 3 3 n n f Ο TRUE FALSE Proof : ) ) lg (( ) ( 2 3 n n O n f combined transitively with ) ( ) lg ( 3 2 n O n n yields ) ( ) ( 3 3 n n f Ο . e) (1 point) )) ( ( ) ( 4 1 n f n f Ω TRUE FALSE Counter-example : 2 1 ) ( n n f = and 3 4 ) ( n n f = 2: (5 points) Recurrence Find a tight upper bound on the closed-form solution for the following recurrence: n n T n T + = ) 1 ( 3 ) ( where T(n) is constant for sufficiently small n . That is, find a function ) ( n g such that )) ( ( ) ( n g O n T . Solution : The Master Theorem does not apply here. A recursion tree can be used. The tree has 1 + n levels if T (0)=1. ) ( 3 i n i work is done at the i th level, except for the bottom level, where n n T 3 ) 0 ( 3 = work is done (thanks to Jane for pointing out the work at the bottom level). The total work is: = + = + = + = = = = = n n i i n i i n n i i n i i n n i i i n i n i n 3 3 3 3 3 3 3 )) ( 3 ( 1 0 1 0 1 0 1 0 1 0 (using closed-form solutions to the summations): ) 3 ( 4 3 2 3 4 7 3 4 3 3 3 ) 1 ( 2 ) 1 3 ( ) 1 ( n n n n n n O n n n n = + + + . Thus, ( ) n O n T 3 ) ( .
UML CS 91.503 Midterm Exam Fall, 2008 3 of 10 3: (5 points) Analyze Pseudocode Mystery 1 has one argument: a positive integer value n . ) ( 1 n Mystery n n " with called Mystery1 " print = 1 if n return then 3 to 1 for i ) 4 / ( 2 do n Mystery return ) ( 2 n Mystery n n " with called Mystery2 " print = 1 if n return then ) 4 / ( 1 n Mystery return Derive a tight upper bound on Mystery 1 ’s worst-case asymptotic running time as a function of n . Solution : In the worst case, let n be a power of 4. ). 1 ( ) 16 / ( 3 )) 16 / ( ) 1 ( ( 3 ) 1 ( ) ( Θ + = + Θ + Θ = n T n T n T Case 1 of the Master Theorem applies, yielding ) ( ) ( 3 log 16 n n T Θ = . So, a tight upper bound is ) ( ) ( 3 log 16 n O n T = .

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

View Full Document
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 / 10

503MidtermExamSolF08 - UML CS 91.503 Midterm Exam Fall 2008...

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

View Full Document
Ask a homework question - tutors are online