1.Easy
In an adjacency list representation of a graph, what is stored for each vertex?
- AThe shortest path to every other vertex
- BThe total number of edges in the graph
- CA list of its neighbouring vertices
- DA row of V Boolean values
2.Easy
What is a deque (double-ended queue)?
- AA structure that allows insertion and removal at both ends
- BA queue sorted by priority
- CTwo separate queues sharing one array
- DA queue that only allows removal at the back
3.Easy
The height of a tree is commonly defined as:
- AThe number of leaves in the tree
- BThe total number of nodes in the tree, counting the root and every leaf
- CThe number of edges on the longest path from the root to a leaf
- DThe number of children of the root
4.Medium
Which abstract data type does Dijkstra's algorithm use to choose the next vertex to process?
- AA set with no ordering
- BA min-priority queue
- CA FIFO queue
- DA stack
5.Medium
What is true of the adjacency matrix of an undirected graph?
- AIts main diagonal always contains ones
- BIt is always upper triangular
- CIt is symmetric about the main diagonal
- DEach row has exactly one 1
6.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
- BArrays use fewer instructions to compare values
- CArray elements are contiguous, so they make good use of the CPU cache
- DArray traversal is O(1) in total, while linked list traversal is O(n)
7.Hard
The union-find (disjoint set) structure with union by rank and path compression has an amortised cost per operation of:
- AO(n²)
- BO(log n) exactly
- CO(α(n)), the inverse Ackermann function, which is practically constant
- DO(n)
8.Hard
Which structure lets you compute the maximum of every window of size k in an array in O(n) total?
- AA deque holding indices in decreasing order of value
- BA singly linked list of the window's elements
- CA min-heap rebuilt for every window
- DA sorted array updated by shifting
Answer key
- 1. C · A list of its neighbouring vertices
- 2. A · A structure that allows insertion and removal at both ends
- 3. C · The number of edges on the longest path from the root to a leaf
- 4. B · A min-priority queue
- 5. C · It is symmetric about the main diagonal
- 6. C · Array elements are contiguous, so they make good use of the CPU cache
- 7. C · O(α(n)), the inverse Ackermann function, which is practically constant
- 8. A · A deque holding indices in decreasing order of value
Full step-by-step solutions: practise this topic on examproblems.com.