Bitkernel · Data Structures & Algorithms
Trace first pass of heap sort
TrueInterview
October 7, 2026 · 1 min read
Take the integer array [7, 6, 3, 5, 4, 1, 2] and run heap sort on it in ascending order with a max-heap.
Once the initial max-heap is built and the first extraction has been performed (swap the root with the final element, then heapify what remains), what order does the array have?
Options:
- A.
1-2-3-4-5-6-7 - B.
2-6-3-5-4-1-7 - C.
6-5-3-2-4-1-7 - D.
5-4-3-2-1-6-7Overview: This question tests your grasp of heap sort and heap operations, in particular max-heap construction, removing the root, and the heapify pass that follows during an in-place array sort.
Loading comments…