cs320-2010-t1-sample-midterm1-solution

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

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

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 :

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 10/09/2011 for the course CPSC 344 taught by Professor Karen during the Fall '10 term at UBC.

### 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
Ask a homework question - tutors are online