1.Easy
What does each node in a doubly linked list contain?
- AData and a pointer to the next node only
- BData and two pointers, one to the next node and one to the node after that
- CData, a pointer to the next node and a pointer to the previous node
- DTwo copies of the data and one pointer
2.Easy
What defines a binary tree?
- AEvery node has exactly two children
- BEvery node stores a binary number
- CEvery node has at most two children
- DThe tree has exactly two levels
3.Easy
In a hash table, what is a collision?
- AA key cannot be hashed at all
- BTwo different keys map to the same index
- CTwo equal keys are stored twice
- DThe table runs out of memory
4.Medium
A binary tree has root 1 with left child 2 and right child 3; node 2 has children 4 (left) and 5 (right). What is the preorder traversal?
- A1 2 4 5 3
- B4 2 5 1 3
- C4 5 2 3 1
- D1 2 3 4 5
5.Medium
An adjacency matrix for a graph with V vertices uses how much memory?
- AO(E)
- BO(V + E)
- CO(log V)
- DO(V²)
6.Medium
A hash table of size 7 uses h(k) = k mod 7 and linear probing. After inserting 10, where is 17 stored?
- AIndex 4
- BIndex 3
- CIndex 0
- DIndex 6
7.Hard
Which data structure supports an LRU (least recently used) cache with O(1) get and put?
- AA single sorted array
- BA binary search tree only
- CA stack only
- DA hash map combined with a doubly linked list
8.Hard
For a hash table to work correctly, which rule must hash and equality follow?
- AEqual keys must have equal hash values
- BEqual hash values imply equal keys
- CHash values must be prime numbers
- DDifferent keys must have different hash values
Answer key
- 1. C · Data, a pointer to the next node and a pointer to the previous node
- 2. C · Every node has at most two children
- 3. B · Two different keys map to the same index
- 4. A · 1 2 4 5 3
- 5. D · O(V²)
- 6. A · Index 4
- 7. D · A hash map combined with a doubly linked list
- 8. A · Equal keys must have equal hash values
Full step-by-step solutions: practise this topic on examproblems.com.