1.Easy
In which order does a postorder traversal of a binary tree visit nodes?
- ARight subtree, then node, then left subtree
- BLeft subtree, then right subtree, then node
- CNode, then left subtree, then right subtree
- DLeft subtree, then node, then right subtree
2.Easy
The depth of a node in a tree is:
- AThe number of edges from that node to the deepest leaf
- BThe number of edges from the root to that node
- CThe number of children of that node
- DThe number of nodes in its subtree
3.Easy
What does a map (dictionary) store?
- AValues sorted by size
- BPairs of equal keys
- COnly values in insertion order
- DKey-value pairs with unique keys
4.Medium
How is a new element inserted into a binary heap?
- APlace it at the end of the array and sift it up while it violates the heap property
- BRebuild the whole heap from scratch
- CPlace it at the root and sift it down
- DInsert it at its sorted position by shifting all of the larger elements one place right
5.Medium
A road network has 100,000 junctions, each connected to about 4 others. Which representation is most suitable?
- AA single sorted array of vertices
- BAdjacency list
- CA binary heap of edges
- DAdjacency matrix
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
How long does it take to search for an arbitrary key in a binary min-heap of n elements?
- AO(log log n)
- BO(log n)
- CO(n)
- DO(1)
8.Hard
In a circular buffer, front == rear can mean either empty or full. What is a common way to tell them apart?
- AKeep a separate element count, or always leave one slot unused
- BStore the front and rear in the same variable
- CAlways clear the buffer whenever front equals rear, so the state is empty
- DMake the buffer size a power of two
Answer key
- 1. B · Left subtree, then right subtree, then node
- 2. B · The number of edges from the root to that node
- 3. D · Key-value pairs with unique keys
- 4. A · Place it at the end of the array and sift it up while it violates the heap property
- 5. B · Adjacency list
- 6. D · O(1)
- 7. C · O(n)
- 8. A · Keep a separate element count, or always leave one slot unused
Full step-by-step solutions: practise this topic on examproblems.com.