1.Easy
Which data structure works on the principle "first in, first out"?
- ABinary tree
- BStack
- CHeap
- DQueue
2.Easy
In a tree, what are sibling nodes?
- AA node and its parent
- BNodes that share the same parent
- CNodes that have no children
- DNodes at the same depth in different subtrees
3.Easy
What is the defining feature of a set as an abstract data type?
- AIt stores key-value pairs
- BIt stores elements without duplicates
- CIt allows access only at one end
- DIt stores elements in sorted order
4.Medium
How long does a search for a word of length L take in a trie with a fixed alphabet?
- AO(L), independent of how many words are stored
- BO(L × n)
- CO(n), where n is the number of words
- DO(log n), where n is the number of words
5.Medium
What is the worst-case height of a binary search tree with n nodes if keys are inserted in sorted order?
- Alog₂ n
- B1
- Cn (it becomes a linked list)
- D√n
6.Medium
You have a reference to a node in the middle of a list. In which list can you remove it in O(1)?
- AA singly linked list
- BA sorted array
- CA doubly linked list
- DA dynamic array
7.Hard
In the BST with root 50, left subtree 30 (children 20, 40) and right subtree 70 (children 60, 80), the root is deleted using the in-order successor. Which key becomes the new root?
- A60
- B40
- C80
- D70
8.Hard
An object is stored as a key in a hash map, and then a field used by its hash function is changed. What is the likely result?
- ANothing changes, because a key's hash is computed only once when the program starts
- BThe map automatically moves the key to its new bucket
- CLooking up the object may fail because it sits in the bucket for its old hash
- DThe map throws an error at the moment the field changes
Answer key
- 1. D · Queue
- 2. B · Nodes that share the same parent
- 3. B · It stores elements without duplicates
- 4. A · O(L), independent of how many words are stored
- 5. C · n (it becomes a linked list)
- 6. C · A doubly linked list
- 7. A · 60
- 8. C · Looking up the object may fail because it sits in the bucket for its old hash
Full step-by-step solutions: practise this topic on examproblems.com.