1.Easy
What defines a binary tree?
- AThe tree has exactly two levels
- BEvery node has exactly two children
- CEvery node has at most two children
- DEvery node stores a binary number
2.Easy
What does the peek (or top) operation on a stack do?
- AReturns the top element without removing it
- BRemoves the top element and returns it
- CReturns the bottom element of the stack
- DRemoves all elements from the stack
3.Easy
In which order does a postorder traversal of a binary tree visit nodes?
- ALeft subtree, then right subtree, then node
- BLeft subtree, then node, then right subtree
- CRight subtree, then node, then left subtree
- DNode, then left subtree, then right subtree
4.Medium
What balance condition does an AVL tree maintain at every node?
- ABoth subtrees of every node contain exactly the same number of nodes
- BThe heights of the left and right subtrees differ by at most 1
- CAll leaves are at exactly the same depth
- DEvery node is coloured red or black
5.Medium
What is the cost of inserting an element in the middle of an array of n elements?
- AO(1), because the index is known
- BO(n²), because each element moves n times
- CO(n), because later elements must shift
- DO(log n), because of binary search
6.Medium
In a hash table using open addressing, what is the maximum possible load factor?
- AThere is no maximum
- B2
- C0.5
- D1
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
- BRecolouring the node and its child
- CA left rotation at the child, then a right rotation at the node
- DA single right rotation at the unbalanced node
8.Hard
Which structure lets you compute the maximum of every window of size k in an array in O(n) total?
- AA deque holding indices in decreasing order of value
- BA singly linked list of the window's elements
- CA sorted array updated by shifting
- DA min-heap rebuilt for every window
Answer key
- 1. C · Every node has at most two children
- 2. A · Returns the top element without removing it
- 3. A · Left subtree, then right subtree, then node
- 4. B · The heights of the left and right subtrees differ by at most 1
- 5. C · O(n), because later elements must shift
- 6. D · 1
- 7. D · A single right rotation at the unbalanced node
- 8. A · A deque holding indices in decreasing order of value
Full step-by-step solutions: practise this topic on examproblems.com.