0

Trace the creation of the heap indicated from the following lists showing each stage of the process

a. {5, 13, 2, 25, 7, 17, 20, 8, 4} min heap enter image description here

I hope I'm doing this right. Before I proceed to next problems I wanted to make sure if this is correct. Any comments or help will be appreciated.

user3478869
  • 105
  • 2
  • 6
  • 12

1 Answers1

0

All good.

Verified with this online visualizers.

Bernhard Barker
  • 54,589
  • 14
  • 104
  • 138
  • Really helpful site thank you for this. Next I want this heap created to sort in descending order is there anything that verifies that you know of? – user3478869 Apr 11 '14 at 21:34
  • Theoretically you could just insert the negative values into the heap, but it doesn't work with that tool. Instead of `x`, you could use `100-x`, so `5` becomes `100-5=95`. Or you could write your own tool, or download the one from the above site and modify it to work with negatives, or, even better, in descending order - I'm sure either of those will teach you a fair amount. – Bernhard Barker Apr 11 '14 at 21:45