33. Suppose you are given a hash table containing N keys. What is the worst-case complexity for
placing the keys into an array in sorted order? (Remember that you can use another algorithm if
needed to order the keys)
(1) O(log(N)
(2) O(N) *
(3) O(N log(N
1. Suppose that you are given an array of N integers. What is the complexity required to print the
first 100 elements (i.e., integers at array indices 0-99)?
*(1) O(1)
(2) O(log(N)
(3) O(N1/2)
(4) O(N)
(5) O(N2)
2. In the array of the previous question, w
20. Suppose N keys are inserted in random order into an initially empty tree using the simple
BST insertion algorithm. What is the complexity to find the largest key in the tree?
(1) O(log(N)
*(2) O(N)
(3) O(N*log(N)
(4) expected O(N*log(N)
(5) O(N2)
21.
16. Suppose that you must maintain a simple circular-linked list with a pointer, rear, that points
to the last item on the list. Which of the following operations cannot be performed in O(1) time?
(1) Putting a new item on the front of the list.
(2) Putti
11. Assume that determining whether an integer is a prime number has O(log(P) 4) complexity,
where P is the number of bits used to represent the integer. Given an array of N integers, each
represented with P bits, what is the complexity to determine wheth
5. Suppose that you are hired by the Computer Dating Services of America (CDSA), a
consortium of computer dating companies. The CDSA tasks you to develop a Java program that
takes as input an array of N questionnaire objects, each of which contains an arr
24. Suppose you know that a collection ADT supports operations that include adding an
item to the collection, checking whether an item is in the collection, deleting an item
from the collection, and checking whether the collection is empty or full. Withou
28. In order to support enqueue and dequeue operations in O(1) time, a circularlinked
implementation of a queue must:
(1) Be doubly-linked
(2) Maintain separate front and rear pointers
(3) Must be doubly-linked with separate front and rear pointers
(4) No
45. What is the complexity of the following pseudocode?
sum
for
for
for
sum
= 0;
(i=0; i < N; i=i+2) cfw_
(j=0; j < N; j=j+2) cfw_
(k=0; k < 4096; k+) cfw_
+= i*j;
(1) O(k*N)
(2) O(k*N2)
(3) O(N1/2)
(4) O O(N1/4) *
(5) O(N2)
46. Which of the following
41. Which of the following is not practical/useful for sorting 100 integers?
(1) Insertion Sort
(2) Quick Sort
(3) Heap Sort
*(4) Hashing
(5) Any of the above is useful for sorting only 100 integers
42. Suppose you are given an unsorted dataset of N real
37. Suppose that you are given an NxN 2-dimensional array and are asked to put the keys in each
row in sorted order. What is the complexity to perform the task?
(1) O(N)
(2) O(N log(N)
(3) O(N2) *
(4) O(N2 log(N)
(5) O(N3)
38. When a wasp returns to its h