Data Structure Time Complexity Question #15265
MCQ Single Best Answer Easy

QWhat is the time complexity of a delete operation in a binary heap in the worst case?

ID: #15265 Time Complexity 182 views
Question Info
#15265Q ID
EasyDifficulty
Time ComplexityTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A O(1)
  • B O(log n)
  • C O(n)
  • D O(n^2)
Correct Answer: Option B

Explanation

In a binary heap, the delete operation removes the root element, which is typically the minimum or maximum element depending on the heap's type. After removing the root, the heap needs to restore the heap property by percolating down or up, which involves swapping elements and comparing them with their children or parent. As the height of a binary heap is logarithmic to the number of elements (n), the worst-case time complexity of a delete operation is O(log n).

Share This Question

Challenge a friend or share with your study group.