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
In a graph, what is a cycle?
- AAn edge with a weight of zero
- BA vertex with no edges
- CA path that visits every vertex
- DA path that starts and ends at the same vertex
3.Easy
Which operation is slow in an array but fast at the head of a linked list?
- AReading the last element by index
- BFinding the length of a fixed array
- CAccessing the 5th element
- DInserting at the beginning
4.Medium
Which abstract data type does Dijkstra's algorithm use to choose the next vertex to process?
- AA stack
- BA FIFO queue
- CA min-priority queue
- DA set with no ordering
5.Medium
How many nodes does a perfect binary tree of height h have, with height counted in edges?
- Ah2
- B2h + 1
- C2h+1 − 1
- D2h
6.Medium
How long does it take to check whether the edge (u, v) exists using an adjacency matrix?
- AO(E)
- BO(V)
- CO(log V)
- DO(1)
7.Hard
Why are B-trees used in databases and file systems?
- ATheir high branching factor keeps the tree shallow, reducing slow disk reads
- BThey need no rebalancing
- CThey use less memory than any array, so the entire index always fits in main memory
- DThey store data unsorted
8.Hard
What is the main advantage of a skip list over a sorted linked list?
- AIt stores keys without order
- BIt uses no extra memory
- CGuaranteed O(1) search because every node stores a pointer to every other node
- DExpected O(log n) search by using several levels of forward pointers
Answer key
- 1. A · Left subtree, then right subtree, then node
- 2. D · A path that starts and ends at the same vertex
- 3. D · Inserting at the beginning
- 4. C · A min-priority queue
- 5. C · 2h+1 − 1
- 6. D · O(1)
- 7. A · Their high branching factor keeps the tree shallow, reducing slow disk reads
- 8. D · Expected O(log n) search by using several levels of forward pointers
Full step-by-step solutions: practise this topic on examproblems.com.