Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

Direction: Consider a binary max-heap implemented using an array :

  1. What is the content of the array after two delete operations on the correct answer to the previous question?
    1. {14, 13, 12, 10, 8}
    2. {14, 12, 13, 8, 10}
    3. {14, 13, 8, 12, 10}
    4. {14, 13, 12, 8, 10}
Correct Option: D

Always a greater element is deleted from the binary heap first. The answer of previous question gave the array as [25, 14, 16, 13, 10, 12, 8]
So, when the greatest element, i.e., 25 is deleted the array becomes [14, 16, 13, 10, 12, 8]
And next after second deletion the array becomes [14, 13, 10, 12, 8]
Thus, the procedure for the obtaining the final tree is as follows.



Your comments will be displayed only after manual approval.