- For the timing information below, what is the complexity?

(a) O(1) (b) O(log n) (c) O(n) (d) O(n log n) (e) O(
)
- For the timing information below, what is the complexity?

(a) O(1) (b) O(log n) (c) O(n) (d) O(n log n) (e) O(
)
- Algorithm C has complexity O(n). What do you expect to happen to
the execution time if the problem size doubles?
- doubles
- slightly more than doubles
- quadruples
- increases by a constant
- Algorithm D has complexity O(
). What do you expect to happen to
the execution time if the problem size doubles?
- stays the same
- doubles
- slightly more than doubles
- quadruples
- increases by a constant
- In hashing, the term primary clustering means that
- the hash function is repeatable
- values that hash to the same orginal location do not keep competing in subsequent
probes.
- values that hash to different orginal locations do not keep competing in subsequent
probes.
- none of the above
- In hashing, what is the advantage of quadratic probing
- primary clustering is eliminated
- secondary clustering is eliminated
- rehashing is rarely necessary
- none of the above
- You have two solutions for the same problem. One is O(
) and the other is
O(n log n). When you compare the times for various problems, the O(n log n) algorithm is
always significantly slower. How do you explain this?
- The clock is not accurate.
- Your problem sizes are too small to see the advantages of the O(n log n) algorithm.
- You are running on a very fast machine.
- The O(
) algorithm has a higher overhead.
- When an exception is thrown, what is true?
- The program will cease execution.
- After the catch statement block
is executed, you resume execution following the catch block.
- The catch statement has no access to information about the exception.
- A catch block cannot throw another exception.
- All of the above.
- When a hash function exhibits primarily clustering, we are concerned because
- You may fail to find items which are present
- The time to find a node can exceed O(log n)
- The hash function becomes non-repeatable.
- Rehashing will not eliminate the clustering.
- You have a hash table of size N with N/2 elements in the table.
In trying to place a new key,
a hash function claims it has made N probes yet it has not found a free location. Which best
explains how this could happen?
- You have primary clustering
- You have secondary clustering
- every unused position is ``Deleted''
- the collision resolution algorithm is in a cyclic state of retrying the same few
locations repeatedly
- Consider the following double hashing algorithm in which each key
has a personalized step function as defined below:
step(key) = 1 + (key mod 8)
= key mod 10
What are the series of locations that will be tried for key = 5 (assuming
that every probe results in a collision)?
- 5,1,7,3,9,5
- 5,9,3,7,1,5
- 5,8,1,4,7,0,3,6,9,2,5
- 5,6,7,8,9,0,1,2,3,4,5
- none of the above
- From our theorem we know:
T(n)= a T(n/b) + O(
)
if
T(n) is O(
)
if
T(n) is O(
)
if
T(n) is O(
)
Consider the following algorithm:
int doit(int A[], int n){
if (n <=1) return 1;
int t;
for (int i =0; i < n; i++)
t++;
t+= 3*doit(A,n/2)
for (int i =0; i < n; i++)
t++;
return t;
}
What is the complexity?
(a) O(1) (b) O(log n) (c) O(n) (d) O(n log n) (e) O(
)
- For the problem above, what are the values of a, b and k?
- a=1, b=1, k=1
- a=1, b=2, k=1
- a=1, b=2, k=0
- a=3, b=2, k=2
- Why is lazy deletion used to delete from a hash table?
- to ensure efficient insertion
- to prevent the search routine from assuming a present item is deleted
- to reduce the load factor
- all of the above
- Consider the following code on a binary tree. What is the result
of the call doit(Tree1)?
- For the code below, what is the result of a call to also(Tree2)?
(a) 10 (b) 12 (c) 62 (d) 37 (e) none of the above
- For the code below, what is the result of a call to compute(Tree3)?
(a) 3 (b) 5 (c) 0 (d) 1 (e) none of the above