1.Easy
In which order does a postorder traversal of a binary tree visit nodes?
- ALeft subtree, then right subtree, then node
- BRight subtree, then node, then left subtree
- CNode, then left subtree, then right subtree
- DLeft subtree, then node, then right subtree
2.Easy
Where is the smallest element of a binary min-heap found?
- AAt the root
- BIn any leaf, which must be searched
- CIn the leftmost leaf
- DIn the last array position
3.Easy
Which operation is slow in an array but fast at the head of a linked list?
- AFinding the length of a fixed array
- BInserting at the beginning
- CAccessing the 5th element
- DReading the last element by index
4.Medium
Why is traversing an array often much faster in practice than traversing a linked list of the same length?
- AArray traversal is O(1) in total, while linked list traversal is O(n)
- BArray elements are contiguous, so they make good use of the CPU cache
- CArrays use fewer instructions to compare values
- DLinked lists always store elements on disk
5.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 3
- CIndex 6
- DIndex 0
6.Medium
What is the worst-case height of a binary search tree with n nodes if keys are inserted in sorted order?
- A1
- Bn (it becomes a linked list)
- C√n
- Dlog₂ n
7.Hard
Which statement about heapsort is correct?
- AIt runs in O(n) time on any input
- BIt is stable and needs O(n) extra memory
- CIt sorts in place in O(n log n) worst-case time but is not stable
- DIt needs a binary search tree as extra storage, so it uses O(n) extra memory
8.Hard
A dynamic array doubles when full. Why do many implementations shrink it only when it is one quarter full, not half full?
- ABecause the memory allocator can only release memory in quarters of a block
- BBecause halving at one half would lose elements
- CTo avoid repeated resizing when pushes and pops alternate near the boundary
- DTo keep the array sorted
Answer key
- 1. A · Left subtree, then right subtree, then node
- 2. A · At the root
- 3. B · Inserting at the beginning
- 4. B · Array elements are contiguous, so they make good use of the CPU cache
- 5. A · Index 4
- 6. B · n (it becomes a linked list)
- 7. C · It sorts in place in O(n log n) worst-case time but is not stable
- 8. C · To avoid repeated resizing when pushes and pops alternate near the boundary
Full step-by-step solutions: practise this topic on examproblems.com.