0

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

yowhatsup123
  • 287
  • 1
  • 11

1 Answers1

1

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
trincot
  • 317,000
  • 35
  • 244
  • 286