1.Easy
In an adjacency list representation of a graph, what is stored for each vertex?
- AA list of its neighbouring vertices
- BA row of V Boolean values
- CThe total number of edges in the graph
- DThe shortest path to every other vertex
2.Easy
In a graph, what is a cycle?
- AA vertex with no edges
- BA path that starts and ends at the same vertex
- CAn edge with a weight of zero
- DA path that visits every vertex
3.Easy
What is the load factor of a hash table?
- AThe number of buckets divided by the average length of the keys stored
- BThe number of stored elements divided by the number of buckets
- CThe number of collisions so far
- DThe time needed to load the table from disk
4.Medium
In a circular queue stored in an array of capacity n, how is the next position after index i computed?
- A2i + 1
- B(i − 1) mod n
- Ci + 1
- D(i + 1) mod n
5.Medium
You have a reference to a node in the middle of a list. In which list can you remove it in O(1)?
- AA dynamic array
- BA doubly linked list
- CA sorted array
- DA singly linked list
6.Medium
AVL trees and red-black trees guarantee:
- AThat keys are stored in insertion order
- BO(log n) height through rebalancing
- CThat no node has two children
- DConstant-time search in every case
7.Hard
The keys 5, 3, 8, 1 are inserted in this order into an empty array-based binary min-heap. What is the final array?
- A[3, 1, 8, 5]
- B[1, 3, 5, 8]
- C[1, 5, 8, 3]
- D[1, 3, 8, 5]
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(n) extra space
- DO(n) time and O(1) extra space
Answer key
- 1. A · A list of its neighbouring vertices
- 2. B · A path that starts and ends at the same vertex
- 3. B · The number of stored elements divided by the number of buckets
- 4. D · (i + 1) mod n
- 5. B · A doubly linked list
- 6. B · O(log n) height through rebalancing
- 7. D · [1, 3, 8, 5]
- 8. D · O(n) time and O(1) extra space
Full step-by-step solutions: practise this topic on examproblems.com.