1.Easy
What does a map (dictionary) store?
- APairs of equal keys
- BKey-value pairs with unique keys
- COnly values in insertion order
- DValues sorted by size
2.Easy
In an undirected graph, what is the degree of a vertex?
- AThe number of edges connected to it
- BIts position in the adjacency list
- CThe length of the longest path from it
- DThe number of vertices in the graph
3.Easy
In which order does a preorder traversal of a binary tree visit nodes?
- ALeft subtree, then node, then right subtree
- BLevel by level from the top
- CNode, then left subtree, then right subtree
- DLeft subtree, then right subtree, then node
4.Medium
How many nodes does a perfect binary tree of height h have, with height counted in edges?
- Ah2
- B2h + 1
- C2h
- D2h+1 − 1
5.Medium
An in-order traversal of a binary search tree visits the keys in:
- AAscending sorted order
- BInsertion order
- CDescending order always
- DLevel order
6.Medium
How do you find the minimum key in a binary search tree?
- AFollow left children from the root until there is no left child
- BVisit every leaf and compare them
- CFollow right children from the root until there is no right child
- DLook at the root only
7.Hard
In a hash table using open addressing, why is deletion often done with a "tombstone" marker?
- ADeleted keys must be kept forever for security, so slots can never be reused
- BTombstones speed up hashing
- CIt makes the table sorted
- DEmptying the slot could break the probe sequence for other keys
8.Hard
What are the time and extra space costs of reversing a singly linked list in place?
- AO(n log n) time and O(1) extra space
- BO(1) time and O(1) extra space
- CO(n) time and O(1) extra space
- DO(n) time and O(n) extra space
Answer key
- 1. B · Key-value pairs with unique keys
- 2. A · The number of edges connected to it
- 3. C · Node, then left subtree, then right subtree
- 4. D · 2h+1 − 1
- 5. A · Ascending sorted order
- 6. A · Follow left children from the root until there is no left child
- 7. D · Emptying the slot could break the probe sequence for other keys
- 8. C · O(n) time and O(1) extra space
Full step-by-step solutions: practise this topic on examproblems.com.