Professional Documents
Culture Documents
A. add
B. append
C. insert
D. push
A. delete
B. peek
C. pop
D. remove
4. Which of the following stack operations could result in stack underflow?
A. is_empty
B. pop
C. push
C. Queues use two ends of the structure; stacks use only one.
D. Stacks use two ends of the structure, queues use only one.
7. If the characters 'D', 'C', 'B', 'A' are placed in a queue (in that order), and then
removed one at a time, in what order will they be removed?
A. ABCD
B. ABDC
C. DCAB
D. DCBA
8. Which of the following expressions evaluates to true with approximate probability
equal to P? (P is double and 0 <= P <= 1).
A. rand() < P
B. rand() > P
A. data[1]
B. data[2]
C. data[11]
D. data[12]
ADBGCFE
and each node of T has either 0 or 2 children, which of the following nodes is
NOT a leaf of that tree?
a. A
b. B
c. C
d. D
e. E
11. Of the following data structures, which would be best suited for an application
where search time must be minimized and where data can be easily added?
12.Of the following, which has the most impact on the efficiency of searching for
i := 1;
Count := 0;
while i < N do
begin
Current := A[i];
while (Current = A[i]) and (i < N) do
i := i + 1;
Count = Count + 1
end
A. O(log N)
B O(√N)
C O(N)
D. O(N log N)
E. O(N2)
14. In the linked-list version of the Queue class, which operations require linear time
for their worst-case behavior?
A. getFront
B. insert
C. isEmpty
15. An array of queues can be used to implement a priority queue, with each possible
priority corresponding to its own element in the array. When is this
implementation not feasible?
A. (rear % 1) + CAPACITY
B. rear % (1 + CAPACITY)
C. (rear + 1) % CAPACITY
D. rear + (1 % CAPACITY)
14
/ \
2 11
/ \ / \
1 3 10 30
/ /
7 40
17. There is a tree at the top of this section. How many leaves does it
have?
A. 2
B. 4
C. 6
D. 8
E. 9
18.There is a tree at the top of this section. How many of the nodes have
A. 5
B. 6
C. 7
D. 8
E. 9
19.There is a tree in the box at the top of this section. What is the value stored in the
parent node of the node containing 30?
A. 10
B. 11
C. 14
D. 40
14
/ \
2 16
/ \
1 5
/
4
Suppose we remove the root, replacing it with something from the left subtree.
What will be the new root?
A. 1
B. 2
C. 4
D. 5
E. 16