A range, a linked chain, and a square region have different boundaries.
What proves each recursive child is smaller and disjoint?
1 / 6
Convert Sorted Array to Binary Search Tree — predict before coding
The middle element balances the number of remaining keys on each side; sorted order simultaneously makes those two ranges valid left and right subtrees.
Decision: For sorted keys [2,5,8,11,14,17], consider midpoint roots 8 and 11. Can both work? A third construction chooses 5, with one key on the left and four balanced keys on the right. Why does sorted inorder alone fail to certify that third root?
2 / 6
Sort List — predict before coding
Merge sort fits linked lists because merging advances pointers, whereas indexed partitioning would repeatedly scan. A recursive split must physically cut the list so each call owns a smaller disjoint chain.
Decision: Distinct nodes arrive as P(2)→Q(1)→R(2)→S(1). Give the stable sorted identity order. Would rewriting their values to 1,1,2,2 while retaining P→Q→R→S satisfy this exercise?
3 / 6
Merge k Sorted Lists — predict before coding
The provided reference is a heap-based k-way merge, not recursive pairwise merge. Both organize partial sorted streams, but their active state and auxiliary-space costs differ.
Decision: Four list lengths are [4,1,1,1]. Charge a merge of nonempty lengths a,b exactly a+b units and forwarding an unpaired run zero. Compare adjacent balanced rounds with left-to-right sequential merging. Why do these totals not determine actual pointer comparison counts?
4 / 6
Construct Quad Tree — predict before coding
A recursive call owns one square region. It may compress that region into one leaf only after proving all its cells equal; otherwise the four child regions partition it exactly.
Decision: A quad tree represents [[0,1],[0,0]] correctly. A learner swaps its TopRight and BottomLeft child pointers while keeping the same leaf values and node count. What grid does it represent afterward, and which validation detects the defect?
5 / 6
Reconstruct and transfer
Explain the split, combine invariant, identity contract, and recurrence for each problem.
Contrast the actual heap reference with pairwise merging.
6 / 6
←/→ or click edges to navigate · ? help · N notes · F fullscreen