# If we implement heap as min-heap, deleting root node (value 1)from the heap. What would be the value of root node after second iteration if leaf node (value 100) is chosen to replace the root at start.

+1 vote
If we implement heap as min-heap, deleting root node (value 1)from the heap. What would be the value of root node after second iteration if leaf node (value 100)  is chosen to replace the root at start.

(a) 2

(b) 100

(c) 17

(d) 3

Query is from Heap in section Heap of Data Structures & Algorithms I

This question was addressed to me in examination.

+1 vote
by (789k points)
selected by

The correct choice is (a) 2

The explanation is: As the root is deleted and node with value 100 is used as replaced one. There is a violation of property that root node must have value less than its children. So there will be shuffling of node with value 100 with node of value 2. And thus 2 becomes root. And it will remain to be at root after all the possible operations. So the value at root will be 2.

+1 vote
+1 vote
+1 vote