1 Consider the following program fragment Stack s spush1 spu
1. Consider the following program fragment:
Stack s;
s.push(1);
s.push(2);
s.push(3);
s.pop();
cout << s.peek() << endl;
Which is the value displayed by the cout statement?
A. 0
B. 1
C. 2
D. 3
2. (TCO 3) To implement the queue ADT with an array, use _____ to represent the ends of the queue.
A. two integers, “front” and “back”
B. a header and a trailer node
C. linked lists
D. a stack and a deque
3. (TCO 3) The priority queue is an ADT that supports which of the following operations?
A. Add, delete, inorder traversal
B. Search, maximum, delete from the front
C. Add, maximum, removeMaximum
D. Minimum, maximum, search
4 (TCO 3) If the numbers 1, 54, 27, 6 are inserted, in that order, in a priority queue, which will be the first element to be removed?
A. 1
B. 54
C. 27
D. 6
5. (TCO 3) Using a doubly-linked list with head and tail references to implement a deque, _____.
A. would require traversing the entire list to add an element at the back
B. would require traversing the entire list to remove the element at the front
C. would require traversing the entire list for removals/insertions at any end
D. no traversal of the list is required for removals/insertions at any end
| A. 0 2. (TCO 3) To implement the queue ADT with an array, use _____ to represent the ends of the queue. A. two integers, “front” and “back” 3. (TCO 3) The priority queue is an ADT that supports which of the following operations? A. Add, delete, inorder traversal 4 (TCO 3) If the numbers 1, 54, 27, 6 are inserted, in that order, in a priority queue, which will be the first element to be removed? A. 1 5. (TCO 3) Using a doubly-linked list with head and tail references to implement a deque, _____.
|
Solution
B
C
A
B
B

