CS 2050
Exam 2
S2009
Instructions
: Mark the single best answer for each of the following 28 questions (scored out of 25).
1. Which of the following best describes an Abstract Data Type (ADT)?
(1) An ADT is an object of a particular class which can be treated as a generic entity.
(2) An ADT is an implementation of a class that uses data hiding and encapsulation.
(3) An ADT is a conceptual entity that can be operated on by a defined set of rules.
(4) An ADT is a class which supports the comparable interface.
(5) An ADT is a class which is declared to be abstract within a Java interface.
2. Which of the following cannot be implemented using a linked list? Mark (5) if all can be.
(1) Stack
(2) Queue
(3) Priority Queue
(4) Bag
(5) All of the above can be implemented with a linked list.
3. Which of the following is most associated with expression "first come, first served"?
(1) Stack
(2) Queue
(3) List
(4) Set
(5) Bag
4. Given a circular linked list implementation of a queue of size N with a single pointer to the node
representing the front of the queue, what is the complexity to perform N dequeue operations?
(1) O(N)
(2) O(N
2
)
(3) O(2
N
)
(4) None of the above because the N dequeues will empty the queue, i.e., leave it with O(1) size.
(5) It is not possible to use a circular linked list without both a front and a rear pointer.
5. What is the complexity to find a specified key in a balanced binary tree which is not necessarily a
BST?
(1) O(log(N))
(2) O(N)
(3) O(N*log(N))
(4) O(N
2
)
(5) A binary tree cannot be searched for a specified key unless it is a BST
6. What is the complexity to find a specified key in a BST which is not necessarily balanced?
(1) O(log(N))
(2) O(N)
(3) O(N*log(N))
(4) O(N
2
)
(5) A BST cannot be searched for a specified key unless it is balanced
7. What is the complexity to find a specified key in a BST which is balanced but not perfectly balanced?
(1) O(log(N))
(2) O(N)
(3) O(N*log(N))
(4) O(N
2
)
(5) A BST cannot be searched for a specified key unless it is perfectly balanced
8. Given a balanced BST, what is the complexity to insert a single new key using the simple BST
insertion algorithm?
(1) O(log(N))
(2) O(N)
(3) O(N*log(N))
(4) O(N
2
)
(5) The complexity depends on whether the tree was constructed from a random sequence of keys
9. Suppose N keys are inserted in random order into a BST using the simple BST insertion algorithm.
What will be the height of the tree?
(1) O(log(N))
(2) O(N)
(3) O(N
2
)
(4) expected O(N
2
)
(5) The height will be determined by the particular order in which the keys are inserted, so
no BigOh expression for the height can be given.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
10. Given the tree of the previous question, what is the complexity to find a specified key?
(1) expected O(log(N))
(2) O(log(N))
(3) expected O(N)
(4) O(N)
(5) O(N
2
)
11. Given a perfectly balanced BST of size N, what is the complexity to determine if a specified key is in
a leaf node?
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '09
 UHLMANN

Click to edit the document details