1.Easy
What does a map (dictionary) store?
- AOnly values in insertion order
- BValues sorted by size
- CPairs of equal keys
- DKey-value pairs with unique keys
2.Easy
What is a weighted graph?
- AA graph in which each edge has a numeric value such as a cost or distance
- BA graph that is stored on disk
- CA graph with more edges than vertices
- DA graph in which some vertices are heavier than others because they have more edges
3.Easy
What does a hash function do in a hash table?
- ASorts the keys in the table
- BCounts how many keys are stored
- CMaps a key to an index in the table
- DEncrypts the values in the table
4.Medium
A trie (prefix tree) is especially efficient for:
- AFinding shortest paths
- BStoring matrices
- CSorting numbers
- DPrefix searches such as autocomplete
5.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 right child, always
- CIts parent, always
- DThe leftmost node of its right subtree
6.Medium
Which data structure is used by depth-first search (iterative version)?
- AA stack
- BA heap
- CA hash table only
- DA queue
7.Hard
Which statement about heapsort is correct?
- AIt is stable and needs O(n) extra memory
- BIt runs in O(n) time on any input
- CIt sorts in place in O(n log n) worst-case time but is not stable
- DIt needs a binary search tree as extra storage, so it uses O(n) extra memory
8.Hard
For each element of an array you want the next greater element to its right, in O(n) total time. Which structure helps?
- AA queue that holds every pair of elements
- BA hash table of all elements
- CA binary search tree rebuilt for each element
- DA stack that keeps elements waiting for their answer
Answer key
- 1. D · Key-value pairs with unique keys
- 2. A · A graph in which each edge has a numeric value such as a cost or distance
- 3. C · Maps a key to an index in the table
- 4. D · Prefix searches such as autocomplete
- 5. D · The leftmost node of its right subtree
- 6. A · A stack
- 7. C · It sorts in place in O(n log n) worst-case time but is not stable
- 8. D · A stack that keeps elements waiting for their answer
Full step-by-step solutions: practise this topic on examproblems.com.