1.Easy
What is a deque (double-ended queue)?
- AA structure that allows insertion and removal at both ends
- BA queue that only allows removal at the back
- CTwo separate queues sharing one array
- DA queue sorted by priority
2.Easy
In a singly linked list, each node contains:
- AData and a reference to the next node
- BOnly data
- CData and references to all other nodes
- DData and an index
3.Easy
A hash table stores data as:
- AA fixed-length string
- BA sorted list only
- CA tree with ordered keys
- DKey–value pairs located by a hash function
4.Medium
A binary tree has root 1 with left child 2 and right child 3; node 2 has children 4 (left) and 5 (right). What is the postorder traversal?
- A4 2 5 1 3
- B4 5 2 3 1
- C5 4 3 2 1
- D1 2 4 5 3
5.Medium
How long does a search for a word of length L take in a trie with a fixed alphabet?
- AO(L × n)
- BO(L), independent of how many words are stored
- CO(log n), where n is the number of words
- DO(n), where n is the number of words
6.Medium
In a binary heap stored in an array starting at index 0, where is the parent of the node at index i?
- AAt index i − 1
- BAt index ⌊i / 2⌋ + 1
- CAt index 2i + 1
- DAt index ⌊(i − 1) / 2⌋
7.Hard
What does a splay tree do after each access?
- ARotates the accessed node up to the root
- BRebuilds the whole tree in balanced form
- CMoves the accessed node to a leaf
- DRecolours the nodes on the search path
8.Hard
For each element of an array you want the next greater element to its right, in O(n) total time. Which structure helps?
- AA queue that holds every pair of elements
- BA binary search tree rebuilt for each element
- CA stack that keeps elements waiting for their answer
- DA hash table of all elements
Answer key
- 1. A · A structure that allows insertion and removal at both ends
- 2. A · Data and a reference to the next node
- 3. D · Key–value pairs located by a hash function
- 4. B · 4 5 2 3 1
- 5. B · O(L), independent of how many words are stored
- 6. D · At index ⌊(i − 1) / 2⌋
- 7. A · Rotates the accessed node up to the root
- 8. C · A stack that keeps elements waiting for their answer
Full step-by-step solutions: practise this topic on examproblems.com.