1.Easy
In an undirected graph, what is the degree of a vertex?
- AThe length of the longest path from it
- BIts position in the adjacency list
- CThe number of edges connected to it
- DThe number of vertices in the graph
2.Easy
In a graph, what is a cycle?
- AA vertex with no edges
- BA path that visits every vertex
- CA path that starts and ends at the same vertex
- DAn edge with a weight of zero
3.Easy
What does a hash function do in a hash table?
- ACounts how many keys are stored
- BEncrypts the values in the table
- CMaps a key to an index in the table
- DSorts the keys in the table
4.Medium
A hash table of size 7 uses h(k) = k mod 7 and linear probing. After inserting 10, where is 17 stored?
- AIndex 4
- BIndex 0
- CIndex 3
- DIndex 6
5.Medium
The keys 50, 30, 70, 20, 40 are inserted in this order into an empty binary search tree. What is the left child of 30?
- A70
- B50
- C20
- D40
6.Medium
Which abstract data type does Dijkstra's algorithm use to choose the next vertex to process?
- AA stack
- BA min-priority queue
- CA set with no ordering
- DA FIFO queue
7.Hard
A Fenwick tree (binary indexed tree) over an array of n numbers supports which operations in O(log n)?
- APrefix-sum queries and single-element updates
- BFinding the median in O(1)
- CSorting the array and binary search
- DInserting elements at any position
8.Hard
You must keep the k smallest values from a stream of n numbers using O(k) memory. Which approach works in O(n log k) time?
- AA min-heap holding all n values, from which the k smallest are popped at the end
- BA FIFO queue of the last k values
- CA max-heap of size k, replacing its root when a smaller value arrives
- DA sorted array of all n values
Answer key
- 1. C · The number of edges connected to it
- 2. C · A path that starts and ends at the same vertex
- 3. C · Maps a key to an index in the table
- 4. A · Index 4
- 5. C · 20
- 6. B · A min-priority queue
- 7. A · Prefix-sum queries and single-element updates
- 8. C · A max-heap of size k, replacing its root when a smaller value arrives
Full step-by-step solutions: practise this topic on examproblems.com.