- GATE CS
- 2026–27 pattern practice
- Data Structures
- Heaps
- Medium
What is the worst-case time to build a binary heap from an unsorted array of elements using the bottom-up (heapify) method?
Trees
Pick an option to check your answer.
Answer: B. Solution
Bottom-up heap construction calls sift-down from the last internal node to the root. A node at height costs , and there are at most nodes at height :
Why not the others
- is the cost of a single insert or delete-min.
- is the cost of building by successive inserts — a valid but loose bound for heapify.
- has no basis for heap construction.