1.Easy
What is the name of the stack operation that adds an element to the top?
- APop
- BPush
- CEnqueue
- DPeek
2.Easy
Which structure is typically used to implement a priority queue?
- AA heap
- BA singly linked list without order
- CA stack
- DA string
3.Easy
In a graph, what is a cycle?
- AAn edge with a weight of zero
- BA path that visits every vertex
- CA path that starts and ends at the same vertex
- DA vertex with no edges
4.Medium
You have a reference to a node in the middle of a list. In which list can you remove it in O(1)?
- AA singly linked list
- BA dynamic array
- CA sorted array
- DA doubly linked list
5.Medium
Which data structure is used by depth-first search (iterative version)?
- AA queue
- BA hash table only
- CA stack
- DA heap
6.Medium
Which data structure does a running program use to keep track of active function calls and their local variables?
- AThe heap memory queue
- BA hash table of functions
- CThe call stack
- DA binary search tree of frames
7.Hard
What is the main advantage of a skip list over a sorted linked list?
- AIt stores keys without order
- BExpected O(log n) search by using several levels of forward pointers
- CGuaranteed O(1) search because every node stores a pointer to every other node
- DIt uses no extra memory
8.Hard
You must keep the k smallest values from a stream of n numbers using O(k) memory. Which approach works in O(n log k) time?
- AA max-heap of size k, replacing its root when a smaller value arrives
- BA sorted array of all n values
- CA min-heap holding all n values, from which the k smallest are popped at the end
- DA FIFO queue of the last k values
Answer key
- 1. B · Push
- 2. A · A heap
- 3. C · A path that starts and ends at the same vertex
- 4. D · A doubly linked list
- 5. C · A stack
- 6. C · The call stack
- 7. B · Expected O(log n) search by using several levels of forward pointers
- 8. A · A max-heap of size k, replacing its root when a smaller value arrives
Full step-by-step solutions: practise this topic on examproblems.com.