1.Easy
What does a map (dictionary) store?
- APairs of equal keys
- BOnly values in insertion order
- CValues sorted by size
- DKey-value pairs with unique keys
2.Easy
In an adjacency list representation of a graph, what is stored for each vertex?
- AThe total number of edges in the graph
- BThe shortest path to every other vertex
- CA row of V Boolean values
- DA list of its neighbouring vertices
3.Easy
How many edges does a tree with n nodes have?
- An
- Bn − 1
- Cn + 1
- D2n
4.Medium
A node in a binary search tree has a right subtree. Where is its in-order successor?
- AThe rightmost node of its left subtree
- BIts parent, always
- CIts right child, always
- DThe leftmost node of its right subtree
5.Medium
Why is traversing an array often much faster in practice than traversing a linked list of the same length?
- ALinked lists always store elements on disk
- BArray traversal is O(1) in total, while linked list traversal is O(n)
- CArrays use fewer instructions to compare values
- DArray elements are contiguous, so they make good use of the CPU cache
6.Medium
A road network has 100,000 junctions, each connected to about 4 others. Which representation is most suitable?
- AAdjacency list
- BA single sorted array of vertices
- CA binary heap of edges
- DAdjacency matrix
7.Hard
Why can elements not simply be deleted from a standard Bloom filter by clearing their bits?
- ABloom filters store the full elements, and these cannot be located again once hashed
- BBits in a Bloom filter cannot be changed after creation
- CDeleting would increase the false positive rate to 100%
- DThose bits may also belong to other elements, which would cause false negatives
8.Hard
In Kruskal's minimum spanning tree algorithm, what is the union-find structure used for?
- AChecking whether an edge's two endpoints are already connected
- BStoring each vertex's current distance from the source during the search
- CSorting the edges by weight
- DChoosing the starting vertex
Answer key
- 1. D · Key-value pairs with unique keys
- 2. D · A list of its neighbouring vertices
- 3. B · n − 1
- 4. D · The leftmost node of its right subtree
- 5. D · Array elements are contiguous, so they make good use of the CPU cache
- 6. A · Adjacency list
- 7. D · Those bits may also belong to other elements, which would cause false negatives
- 8. A · Checking whether an edge's two endpoints are already connected
Full step-by-step solutions: practise this topic on examproblems.com.