1.Easy
In a graph, what is a cycle?
- AA path that starts and ends at the same vertex
- BAn edge with a weight of zero
- CA vertex with no edges
- DA path that visits every vertex
2.Easy
What does each node in a doubly linked list contain?
- AData and two pointers, one to the next node and one to the node after that
- BData and a pointer to the next node only
- CData, a pointer to the next node and a pointer to the previous node
- DTwo copies of the data and one pointer
3.Easy
What is a directed graph?
- AA graph whose edges all have weights
- BA graph in which every pair of distinct vertices is joined by an edge
- CA graph whose edges have a direction from one vertex to another
- DA graph that has no cycles
4.Medium
Which data structure is used to check whether the brackets in "{[()]}" are balanced?
- AA stack
- BA binary search tree
- CA queue
- DA hash table
5.Medium
What happens when a hash table rehashes after its load factor exceeds a threshold?
- AA larger table is allocated and every key is inserted again
- BThe oldest keys are deleted to make room
- CThe existing keys are sorted in place
- DOnly the colliding keys are moved to a new overflow list at the end of the table
6.Medium
Which collision resolution method stores colliding keys in a list at the same bucket?
- ASeparate chaining
- BQuadratic probing
- CLinear probing
- DDouble hashing
7.Hard
Which property keeps every B-tree perfectly balanced?
- AEach node stores one key
- BAll leaves are at the same depth
- CThe keys are stored only in the root
- DEvery node has exactly two children
8.Hard
What are the time and extra space costs of reversing a singly linked list in place?
- AO(n) time and O(n) extra space
- BO(n log n) time and O(1) extra space
- CO(n) time and O(1) extra space
- DO(1) time and O(1) extra space
Answer key
- 1. A · A path that starts and ends at the same vertex
- 2. C · Data, a pointer to the next node and a pointer to the previous node
- 3. C · A graph whose edges have a direction from one vertex to another
- 4. A · A stack
- 5. A · A larger table is allocated and every key is inserted again
- 6. A · Separate chaining
- 7. B · All leaves are at the same depth
- 8. C · O(n) time and O(1) extra space
Full step-by-step solutions: practise this topic on examproblems.com.