1.Easy
What does the peek (or top) operation on a stack do?
- ARemoves the top element and returns it
- BRemoves all elements from the stack
- CReturns the top element without removing it
- DReturns the bottom element of the stack
2.Easy
Which data structure is most suitable for the "undo" feature in a text editor?
- AQueue
- BStack
- CHash set
- DGraph
3.Easy
In a tree, what is a leaf?
- AThe node with the largest value
- BA node with no children
- CA node with no parent
- DA node with exactly one child
4.Medium
A circular buffer (ring buffer) is commonly used to implement:
- AA fixed-size queue
- BA hash function
- CA binary search tree
- DA graph traversal
5.Medium
An adjacency matrix for a graph with V vertices uses how much memory?
- AO(V + E)
- BO(log V)
- CO(E)
- DO(V²)
6.Medium
How long does a search for a word of length L take in a trie with a fixed alphabet?
- AO(n), where n is the number of words
- BO(L × n)
- CO(log n), where n is the number of words
- DO(L), independent of how many words are stored
7.Hard
For each element of an array you want the next greater element to its right, in O(n) total time. Which structure helps?
- AA hash table of all elements
- BA stack that keeps elements waiting for their answer
- CA binary search tree rebuilt for each element
- DA queue that holds every pair of elements
8.Hard
Which property keeps every B-tree perfectly balanced?
- AEvery node has exactly two children
- BAll leaves are at the same depth
- CThe keys are stored only in the root
- DEach node stores one key
Answer key
- 1. C · Returns the top element without removing it
- 2. B · Stack
- 3. B · A node with no children
- 4. A · A fixed-size queue
- 5. D · O(V²)
- 6. D · O(L), independent of how many words are stored
- 7. B · A stack that keeps elements waiting for their answer
- 8. B · All leaves are at the same depth
Full step-by-step solutions: practise this topic on examproblems.com.