#8 Perform a two deletions on the following binary heap. Enter the resulting heap and draw the heaped tree too:
#8 Perform a two deletions on the following binary heap. Enter the resulting
heap and draw the heaped tree too:


Given Array:
{2, 3, 4, 8, 9, 12, 9, 10}
Forming Min heap from the array:
Note: Since your are not mentioning the order of the heap, here we are using minimum heap order.
Steps to deque an element from the array:
- Remove the minimum element from the heap.
- Replace the removed element with last node of the heap.
- Compare the values with child, if there a need for swap, swap the nodes.
- Continue this until, the heap to satisfies to its conditions.
Removing minimum element from the heap:
Replacing the root node with final leaf node(12):
Comparing the root node with child node:
Here, the value of root is 12 and the value of minimum child node is 3. Therefore, swap the nodes.
Now, again swap the node 12 with node 8, because node 8 is the minimum than node 12.
The above heap represents the deletion of first deletion.
Again, follow the same process for second deletion.
Step by step
Solved in 9 steps with 9 images









