quiz3 - n elements has worst-case time complex-ity O log...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Quiz 3 CS 2110 March 15 Name: NetId: 1. Suppose we are making a method that prints Lists with elements of any type. What would be an appropriate signature for this method? (a) public void print(List<Object> list) (b) public void print(List < ? > list) (c) public void print(LinkedList<? extends Comparable> list) (d) public void print(List<? extends Comparable> list) 2. Select the statement that is false. (a) Binary search in a sorted array with n elements has average-case time complexity O(log(n)) . (b) Binary search in a sorted array with n elements has worst-case time complexity O(log(n)) . (c) Finding an element in a BST with
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: n elements has worst-case time complex-ity O ( log ( n )) . (d) Inserting n elements into an unsorted linked list can be done in worst-case time O(n) . 3. What is the time complexity of the code below? Choose the tightest bound. int count = 0; for(int i = 0; i < n + 5; i++){ for(int j = 0; j < n*n*n; j++){ count++; } } (a) O( n 4 ) (b) O( n 3 ) (c) O( n 2 ) (d) O( n ) 4. Which of these is a design pattern? (a) Scientist (b) Observer (We gave everyone this point as it wasn’t covered in class before the quiz) (c) Sniper (d) Engineer 1...
View Full Document

This note was uploaded on 09/17/2011 for the course CS 2110 taught by Professor Francis during the Spring '07 term at Cornell.

Ask a homework question - tutors are online