Checking if Inserting values in order into an initially empty minimum binary heap is correct

22 Views Asked by At

Can someone tell me if I have produced the right minimum binary heap after inserting these values in order into an initially empty minimum binary heap?

[23, 41, 19, 59, 10, 15, 40]

enter image description here

1

There are 1 best solutions below

0
trincot On BEST ANSWER

Yes. That is the correct result for that input.

The heap evolves as follows:

       23
      _23
     /  
   41
      _19_
     /    \
   41      23
      _19_
     /    \
   41      23
  /
 59
      _10_
     /    \
   19      23
  /  \
 59  41
      _10_
     /    \
   19      15
  /  \    /
 59  41  23
      _10_
     /    \
   19      15
  /  \    /  \
 59  41  23  40