1.Easy
In an undirected graph, what is the degree of a vertex?
- AIts position in the adjacency list
- BThe length of the longest path from it
- CThe number of vertices in the graph
- DThe number of edges connected to it
2.Easy
What does a hash function do in a hash table?
- AMaps a key to an index in the table
- BSorts the keys in the table
- CCounts how many keys are stored
- DEncrypts the values in the table
3.Easy
Which data structure is most suitable for the "undo" feature in a text editor?
- AHash set
- BQueue
- CGraph
- DStack
4.Medium
What is the time complexity of searching for a key in a balanced binary search tree?
- AO(1)
- BO(n)
- CO(log n)
- DO(n log n)
5.Medium
How long does a search for a word of length L take in a trie with a fixed alphabet?
- AO(L × n)
- BO(log n), where n is the number of words
- CO(n), where n is the number of words
- DO(L), independent of how many words are stored
6.Medium
In a circular queue stored in an array of capacity n, how is the next position after index i computed?
- Ai + 1
- B(i − 1) mod n
- C2i + 1
- D(i + 1) mod n
7.Hard
Which structure lets you compute the maximum of every window of size k in an array in O(n) total?
- AA sorted array updated by shifting
- BA min-heap rebuilt for every window
- CA singly linked list of the window's elements
- DA deque holding indices in decreasing order of value
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) time and O(1) extra space
- CO(1) time and O(1) extra space
- DO(n log n) time and O(1) extra space
Answer key
- 1. D · The number of edges connected to it
- 2. A · Maps a key to an index in the table
- 3. D · Stack
- 4. C · O(log n)
- 5. D · O(L), independent of how many words are stored
- 6. D · (i + 1) mod n
- 7. D · A deque holding indices in decreasing order of value
- 8. B · O(n) time and O(1) extra space
Full step-by-step solutions: practise this topic on examproblems.com.