What is the time complexity of extracting the maximum element from a binary max-heap of n elements?

  • A O(1)
  • B O(n)
  • C O(log n)
  • D O(n log n)

Explanation

After removing the root, the last element moves to the root and is sifted down through at most log n levels, giving O(log n) time.