This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: York University CSE 2011Z Winter 2010 – Midterm Tues Feb 23 Instructor: James Elder 1. (5 marks) BigOh Definition Fill in the blanks: f ( n ) ∈ O ( g ( n )) iff c > , n > , such that n n ,f ( n ) cg ( n ) • Answer: f ( n ) ∈ O ( g ( n )) iff ∃ c > , ∃ n > , such that ∀ n ≥ n , f ( n ) ≤ cg ( n ) 2. (4 × 3 = 12 marks) Asymptotic Running Times True or False? All logarithms are base 2. No justification is necessary. (a) 5 n 2 log n ∈ O ( n 2 ) • Answer: False. It is a factor of log n too big. (b) 4 8 n ∈ O (8 4 n ) • Answer: False: 4 8 n = 2 16 n , but 8 4 n = 2 12 n . (c) 2 10 log n + 100(log n ) 11 ∈ O ( n 10 ) • Answer: True: 2 10 log n = n 10 , 100(log n ) 11 ∈ O ( n 10 ). (d) 2 n 2 log n + 3 n 2 ∈ Θ( n 3 ) • Answer: False: 2 n 2 log n + 3 n 2 ∈ O ( n 3 ), but 2 n 2 log n + 3 n 2 / ∈ Ω( n 3 ). 1 3. (6 × 3 = 18 marks) Choosing a data structure State in one or two words the simplest ADT and implementation we have discussed that would meet each requirement. (a) O(1) time removal of the most recently added element ADT: Implementation: • Answer: Arraybased stack (b) O(1) average time addition, removal, access and modification of (key, value) pairs with unique keys ADT: Implementation: • Answer: ADT: Map, Implementation: Hash table (c) O(1) time insertion and removal at a given position ADT: Implementation:...
View
Full
Document
This note was uploaded on 10/28/2010 for the course CSE 2011 taught by Professor Someone during the Summer '10 term at York University.
 Summer '10
 someone

Click to edit the document details