1.Easy
What does each node in a doubly linked list contain?
- AData, a pointer to the next node and a pointer to the previous node
- BData and two pointers, one to the next node and one to the node after that
- CData and a pointer to the next node only
- DTwo copies of the data and one pointer
2.Easy
In which order does a preorder traversal of a binary tree visit nodes?
- ALeft subtree, then right subtree, then node
- BLeft subtree, then node, then right subtree
- CLevel by level from the top
- DNode, then left subtree, then right subtree
3.Easy
Which data structure works on the principle "first in, first out"?
- ABinary tree
- BStack
- CQueue
- DHeap
4.Medium
What is the cost of inserting an element in the middle of an array of n elements?
- AO(log n), because of binary search
- BO(n), because later elements must shift
- CO(1), because the index is known
- DO(n²), because each element moves n times
5.Medium
What balance condition does an AVL tree maintain at every node?
- AThe heights of the left and right subtrees differ by at most 1
- BEvery node is coloured red or black
- CBoth subtrees of every node contain exactly the same number of nodes
- DAll leaves are at exactly the same depth
6.Medium
An application needs fast lookups and also needs to list keys in sorted order and answer range queries. Which structure fits best?
- AA balanced binary search tree
- BA hash table
- CA stack
- DAn unsorted linked list
7.Hard
In a circular buffer, front == rear can mean either empty or full. What is a common way to tell them apart?
- AKeep a separate element count, or always leave one slot unused
- BAlways clear the buffer whenever front equals rear, so the state is empty
- CMake the buffer size a power of two
- DStore the front and rear in the same variable
8.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
Answer key
- 1. A · Data, a pointer to the next node and a pointer to the previous node
- 2. D · Node, then left subtree, then right subtree
- 3. C · Queue
- 4. B · O(n), because later elements must shift
- 5. A · The heights of the left and right subtrees differ by at most 1
- 6. A · A balanced binary search tree
- 7. A · Keep a separate element count, or always leave one slot unused
- 8. D · A single right rotation at the unbalanced node
Full step-by-step solutions: practise this topic on examproblems.com.