1.Easy
What is a deque (double-ended queue)?
- AA structure that allows insertion and removal at both ends
- BA queue sorted by priority
- CTwo separate queues sharing one array
- DA queue that only allows removal at the back
2.Easy
The height of a tree is commonly defined as:
- AThe number of leaves in the tree
- BThe number of edges on the longest path from the root to a leaf
- CThe number of children of the root
- DThe total number of nodes in the tree, counting the root and every leaf
3.Easy
Which operation is O(1) for an array but O(n) for a singly linked list?
- AAccessing the element at index i
- BInserting at the head
- CRemoving the head element
- DReading the first element
4.Medium
A trie (prefix tree) is especially efficient for:
- APrefix searches such as autocomplete
- BStoring matrices
- CSorting numbers
- DFinding shortest paths
5.Medium
How does extract-min work in a binary min-heap?
- ARemove the last element of the array
- BRemove the root and shift all elements one place left
- CMove the last element to the root and sift it down
- DSearch all leaves for the new minimum
6.Medium
In a circular queue stored in an array of capacity n, how is the next position after index i computed?
- Ai + 1
- B2i + 1
- C(i − 1) mod n
- D(i + 1) mod n
7.Hard
A dynamic array doubles when full. Why do many implementations shrink it only when it is one quarter full, not half full?
- ATo keep the array sorted
- BBecause halving at one half would lose elements
- CTo avoid repeated resizing when pushes and pops alternate near the boundary
- DBecause the memory allocator can only release memory in quarters of a block
8.Hard
What guarantee do the red-black tree rules give about the height of a tree with n keys?
- AThe height is at most n / 2
- BThe height is exactly log2 n
- CThe height is at most 2 log2(n + 1)
- DThe height is at most log2 n + 1
Answer key
- 1. A · A structure that allows insertion and removal at both ends
- 2. B · The number of edges on the longest path from the root to a leaf
- 3. A · Accessing the element at index i
- 4. A · Prefix searches such as autocomplete
- 5. C · Move the last element to the root and sift it down
- 6. D · (i + 1) mod n
- 7. C · To avoid repeated resizing when pushes and pops alternate near the boundary
- 8. C · The height is at most 2 log2(n + 1)
Full step-by-step solutions: practise this topic on examproblems.com.