- GATE CS
- 2026–27 pattern practice
- Data Structures
- Heaps
- Easy
What is the worst-case time to delete the maximum element from a binary max-heap of elements?
Trees
Pick an option to check your answer.
Answer: C. Solution
Delete-max swaps the root with the last element, shrinks the heap by one, and sifts the new root down. Each sift-down step moves one level, and a heap of elements has height , so the work is .
Why not the others
- is only the time to read the maximum at the root; removing it also needs the heap to be repaired.
- would be needed only if we searched the whole array, which a heap avoids.
- is the cost of heapsort on all elements, not of one deletion.