cs320-2010-t1-sample-midterm1-solution

cs320-2010-t1-sample-midterm1-solution - CPSC 320 Sample...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CPSC 320 Sample Midterm 1 October 2010 [12] 1. Answer each of the questions with either true or false . You must justify each of your answers; an answer without a justification will be worth at most 1.5 out of 4. [4] a. 3 n +2 + 5 O (3 n 1 ) . Solution : This is true. Here are two proofs of this fact: Using limits: lim n →∞ (3 n +2 + 5) / 3 n 1 = lim n →∞ 3 n +2 / 3 n 1 + lim n →∞ 5 / 3 n 1 = 27 + 0 = 27 Hence 3 n +2 + 5 Θ(3 n 1 ) . Using the definition of O : pick c = 32 and n 0 = 1 . Then 3 n +2 +5 = 27 · 3 n 1 + 5 27 · 3 n 1 + 5 · 3 n 1 (for n 1 ), and so 3 n +2 + 5 32 · 3 n 1 = c 3 n 1 . [4] b. Let f, g be two functions from N into R + . Assuming that lim n →∞ f ( n ) /g ( n ) exists, we can use its value to determine whether or not f is in O ( g ) . Solution : This is true: if lim n →∞ f ( n ) /g ( n ) = 0 then f o ( g ) , and hence f O ( g ) . If lim n →∞ f ( n ) /g ( n ) is a positive real number, then f Θ( g ) and so f O ( g ) . Finally if lim n →∞ f ( n ) /g ( n ) = + then f ω ( g ) , and therefore f / O ( g ) . [4] c. In class, we proved an Ω( n log n ) lower bound on the worst-case running time of any algorithm that can be used to sort a sequence of n values. Solution :
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

cs320-2010-t1-sample-midterm1-solution - CPSC 320 Sample...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online