1.Easy
Which data structure is most suitable for the "undo" feature in a text editor?
- AGraph
- BHash set
- CStack
- DQueue
2.Easy
In a singly linked list, each node contains:
- AOnly data
- BData and an index
- CData and a reference to the next node
- DData and references to all other nodes
3.Easy
What is the name of the stack operation that adds an element to the top?
- APush
- BPeek
- CEnqueue
- DPop
4.Medium
What is the worst-case height of a binary search tree with n nodes if keys are inserted in sorted order?
- Alog₂ n
- B√n
- Cn (it becomes a linked list)
- D1
5.Medium
What balance condition does an AVL tree maintain at every node?
- AAll leaves are at exactly the same depth
- BEvery node is coloured red or black
- CThe heights of the left and right subtrees differ by at most 1
- DBoth subtrees of every node contain exactly the same number of nodes
6.Medium
AVL trees and red-black trees guarantee:
- AThat no node has two children
- BO(log n) height through rebalancing
- CConstant-time search in every case
- DThat keys are stored in insertion order
7.Hard
Why are B-trees used in databases and file systems?
- AThey need no rebalancing
- BThey store data unsorted
- CTheir high branching factor keeps the tree shallow, reducing slow disk reads
- DThey use less memory than any array, so the entire index always fits in main 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 FIFO queue of the last k values
- CA min-heap holding all n values, from which the k smallest are popped at the end
- DA sorted array of all n values
Answer key
- 1. C · Stack
- 2. C · Data and a reference to the next node
- 3. A · Push
- 4. C · n (it becomes a linked list)
- 5. C · The heights of the left and right subtrees differ by at most 1
- 6. B · O(log n) height through rebalancing
- 7. C · Their high branching factor keeps the tree shallow, reducing slow disk reads
- 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.