1.Easy
Which operation is O(1) for an array but O(n) for a singly linked list?
- AReading the first element
- BInserting at the head
- CRemoving the head element
- DAccessing the element at index i
2.Easy
What defines a binary tree?
- AEvery node has at most two children
- BThe tree has exactly two levels
- CEvery node has exactly two children
- DEvery node stores a binary number
3.Easy
What does the peek (or top) operation on a stack do?
- AReturns the bottom element of the stack
- BRemoves the top element and returns it
- CRemoves all elements from the stack
- DReturns the top element without removing it
4.Medium
An adjacency matrix for a graph with V vertices uses how much memory?
- AO(V²)
- BO(log V)
- CO(E)
- DO(V + E)
5.Medium
A node in a binary search tree has a right subtree. Where is its in-order successor?
- AIts right child, always
- BThe rightmost node of its left subtree
- CThe leftmost node of its right subtree
- DIts parent, always
6.Medium
What is the purpose of a sentinel (dummy) node in a linked list?
- ATo prevent the list from growing beyond a fixed maximum number of nodes
- BTo store the number of elements
- CTo make the list sorted
- DTo simplify code by removing special cases at the head or tail
7.Hard
Why might a server choose its hash function at random from a universal family?
- ATo remove the need to resize the table
- BTo make it very unlikely that an attacker can pick many keys that all collide
- CTo guarantee that no two keys can ever collide, whatever keys an attacker sends
- DTo make the hash table sorted
8.Hard
The keys 5, 3, 8, 1 are inserted in this order into an empty array-based binary min-heap. What is the final array?
- A[1, 3, 5, 8]
- B[3, 1, 8, 5]
- C[1, 5, 8, 3]
- D[1, 3, 8, 5]
Answer key
- 1. D · Accessing the element at index i
- 2. A · Every node has at most two children
- 3. D · Returns the top element without removing it
- 4. A · O(V²)
- 5. C · The leftmost node of its right subtree
- 6. D · To simplify code by removing special cases at the head or tail
- 7. B · To make it very unlikely that an attacker can pick many keys that all collide
- 8. D · [1, 3, 8, 5]
Full step-by-step solutions: practise this topic on examproblems.com.