What is the time complexity of building a binary heap from an unsorted array of n elements using bottom-up heapify?
- A O(n log n)
- B O(n)
- C O(log n)
- D O(n^2)
Explanation
Bottom-up heap construction runs in O(n) time, even though a naive repeated insertion would take O(n log n).