Other / Mixed Topics

Answer & solution
Official answer: A
P: join the first list's tail to the second list's head, set the corresponding previous pointer, and choose the resulting head and tail. Only a constant number of pointer changes are needed, with separate constant-time handling of empty lists. The list is unsorted, so no ordering merge is required: Θ(1).
Q: place both arrays into one 2n-element array and apply bottom-up build-heap. Build-heap is linear, not Θ(n log n): there are many nodes near leaves that require only short sift-down operations, and summing their heights gives O(n). The concatenation/output work is also linear, so Θ(n) suffices. Inserting each item separately is valid but needlessly slower in the worst case.
R: perform inorder traversals to get two sorted sequences in Θ(n), merge them in Θ(n), and build a balanced BST from the merged sequence by choosing midpoints recursively in Θ(n). Arbitrarily interleaved key sets require linear worst-case work/comparisons to establish their joint ordering, so the meld bound is Θ(n), rather than the cost of repeated naive insertions into a possibly skewed tree.
The three bounds are Θ(1),Θ(n),Θ(n): A.
![Question 48, GATE 2015: Young tableau rows[1, 2, 5, 14], [3, 4, 6, 23], [10, 12, 18, 25], [31, ∞, ∞, ∞], increasing rows/columns. Remove 1 and move other entries so that the result remains a Young tableau, allowing unfilled entries to be marked ∞. What is the minimum number of other entries shifted? The solution below uses the conventional adjacent-hole deletion algorithm.](../../../assets/questions/CS-2015-S2-Q48-1.webp)
