Sample Exams

# Sample Exams - CS 2050 Final Exam Spring 2009 Instructions...

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

CS 2050 Final Exam Spring 2009 Instructions : Same as previous exams - mark the single best answer for each of the following questions. 1. Given a linked list of N keys in sorted order, what is the complexity to determine if a specified key is in the list? (1) O(log(N)) (2) O((log(N)) 2 ) (3) O(N) (4) O(N log(N)) (5) O(N 2 ) 2. Given an array of keys in unknown order, what is the complexity to determine if a specified key is in the array? (1) O(log(N)) (2) O((log(N)) 2 ) (3) O(N) (4) O(N log(N)) (5) O(N 2 ) 3. Given an array of keys in sorted order, what is the complexity to determine if a specified key is in the array? (1) O(log(N)) (2) O((log(N)) 2 ) (3) O(N) (4) O(N log(N)) (5) O(N 2 ) 4. Given an array of keys in unknown order, what is the complexity required to sort the keys and apply binary search to determine if a specified key is in the list? (1) O((log(N)) 2 ) (2) O(N) (3) O(N log(N)) (4) O(N (log(N)) 2 ) (5) O(N 2 ) 5. Suppose that you are implementing Interpolation Sort, and you store keys that are mapped to the same index in a simple linked list, in sorted order, associated with that index. What is the complexity of the overall sorting algorithm? (1) O(N log(log(N))) (2) O(N log(N)) (3) O(N (log(N)) 2 ) (4) O(N 2 ) (5) O(N 2 log(N)) 6. Suppose that you are implementing Interpolation Sort, and you store keys that are mapped to the same index in a heap associated with that index. What is the complexity of the overall sorting algorithm? (1) O(N log(log(N))) (2) O(N log(N)) (3) O(N (log(N)) 2 ) (4) O(N 2 ) (5) O(N 2 log(N)) 7. Suppose that a hash table is implemented using heaps to store keys that are mapped to the same indices. What is the complexity for retrieving a specified key? (1) O(1) (2) O(log(N)) (3) O(N) (4) O(N*log(N)) (5) O(N 2 ) 8. Given a balanced BST containing N character strings, each of which has length P, what is the complexity to determine whether a given string is or is not in the tree? (NOTE: Consider the complexity to compare strings) (1) O(log(N)) (2) O(log(PN)) (3) O(P+log(N) (4) O(P*log(N)) (5) O(N*log(P)) 9. Given N linked lists, each containing 5000 names, what is the complexity sorting all of the lists, i.e., so that every list is alphabetized)? Hint: Be careful (1) O(N) (2) O(N log(N)) (3) O(N 2 log(N)) (4) O(N 5000 log(N)) (5) O(5000 N log(N)) 10. Given an array of integers with N rows and N columns, what is the complexity of determining if any of the numbers in the array are zero? (1) O(1) (2) O(log(N)) (3) O(N) (4) O(N log(N)) (5) O(N 2 )

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

View Full Document
11. Given an array of N integers in unknown order, what is the complexity of determining the sorted order rank of the value in the first element of the array? (1) O(1) (2) O(log(N)) (3) O(N) (4) O(N log(N)) (5) O(N 2 ) 12. Given an array of N integers in ascending sorted order, what is the complexity of determining the sorted order rank of the value in the middle element of the array? (1)
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 72

Sample Exams - CS 2050 Final Exam Spring 2009 Instructions...

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

View Full Document
Ask a homework question - tutors are online