1.Easy
In a tree, what is a leaf?
- AA node with no children
- BThe node with the largest value
- CA node with exactly one child
- DA node with no parent
2.Easy
What is the name of the stack operation that adds an element to the top?
- APop
- BPush
- CPeek
- DEnqueue
3.Easy
What is a directed graph?
- AA graph in which every pair of distinct vertices is joined by an edge
- BA graph that has no cycles
- CA graph whose edges all have weights
- DA graph whose edges have a direction from one vertex to another
4.Medium
AVL trees and red-black trees guarantee:
- AThat no node has two children
- BThat keys are stored in insertion order
- CConstant-time search in every case
- DO(log n) height through rebalancing
5.Medium
A node in a binary search tree has a right subtree. Where is its in-order successor?
- AIts parent, always
- BThe leftmost node of its right subtree
- CIts right child, always
- DThe rightmost node of its left subtree
6.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
- CSearch all leaves for the new minimum
- DMove the last element to the root and sift it down
7.Hard
Inserting a key into an AVL tree makes a node's left subtree too tall, and the new key went into the left subtree of its left child (left-left case). Which fix is applied?
- AA single left rotation at the unbalanced node
- BA left rotation at the child, then a right rotation at the node
- CRecolouring the node and its child
- DA single right rotation at the unbalanced node
8.Hard
Which problem of linear probing does double hashing mainly reduce?
- AThe O(n) cost of reading a key's value
- BThe need for a hash function
- CThe need to store keys in the table
- DPrimary clustering, where long runs of occupied slots form
Answer key
- 1. A · A node with no children
- 2. B · Push
- 3. D · A graph whose edges have a direction from one vertex to another
- 4. D · O(log n) height through rebalancing
- 5. B · The leftmost node of its right subtree
- 6. D · Move the last element to the root and sift it down
- 7. D · A single right rotation at the unbalanced node
- 8. D · Primary clustering, where long runs of occupied slots form
Full step-by-step solutions: practise this topic on examproblems.com.