1.Easy
What is the root of a tree?
- AThe node with the largest value
- BThe top node with no parent
- CAny node in the middle
- DA node with no children
2.Easy
In a singly linked list, what does the next pointer of the last node contain?
- ANull (no node)
- BThe address of the first node
- CThe number of nodes in the list
- DThe address of the previous node
3.Easy
What does the peek (or top) operation on a stack do?
- AReturns the top element without removing it
- BRemoves the top element and returns it
- CRemoves all elements from the stack
- DReturns the bottom element of the stack
4.Medium
A trie (prefix tree) is especially efficient for:
- AStoring matrices
- BPrefix searches such as autocomplete
- CSorting numbers
- DFinding shortest paths
5.Medium
What is true of the adjacency matrix of an undirected graph?
- AIts main diagonal always contains ones
- BIt is symmetric about the main diagonal
- CIt is always upper triangular
- DEach row has exactly one 1
6.Medium
A queue is implemented with two stacks: push onto an "in" stack, and pop from an "out" stack, refilling it from "in" when empty. What is the amortised cost per operation?
- AO(n)
- BO(log n)
- CO(n²)
- DO(1)
7.Hard
Under simple uniform hashing, what is the expected time of a search in a hash table with chaining, n keys and m buckets?
- AO(1 + α), where α = n / m
- BO(m)
- CO(n)
- DO(log n)
8.Hard
Which statement about heapsort is correct?
- AIt needs a binary search tree as extra storage, so it uses O(n) extra memory
- BIt runs in O(n) time on any input
- CIt is stable and needs O(n) extra memory
- DIt sorts in place in O(n log n) worst-case time but is not stable
Answer key
- 1. B · The top node with no parent
- 2. A · Null (no node)
- 3. A · Returns the top element without removing it
- 4. B · Prefix searches such as autocomplete
- 5. B · It is symmetric about the main diagonal
- 6. D · O(1)
- 7. A · O(1 + α), where α = n / m
- 8. D · It sorts in place in O(n log n) worst-case time but is not stable
Full step-by-step solutions: practise this topic on examproblems.com.