Question discussion

What is the time complexity of building a binary heap from n elements using the bottom-up (heapify) method?

1106Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the time complexity of building a binary heap from n elements using the bottom-up (heapify) method?

  • AΘ(log n)
  • BΘ(n²)
  • CΘ(n log n)
  • DΘ(n)
Correct answer: D

Explanation

Most nodes are near the leaves and sift down only a few levels, so the total work sums to Θ(n).

Discussion 0

Nobody has replied yet. Start the discussion!