The heaps we have considered are called min-heaps, because the minimum value is at the root. If we reverse the second heap condition—that is, we write
we will get the largest value at the top of the heap. This is called a max-heap. We can define find-max, insert, delete-max and update for max-heaps along the same lines as we did for min-heaps.
©IARCS 2012–2016
Pěstujeme web | visit: Skluzavky