Up-Heapify

A bit simpler.

Look at node i (initially i=n).

We know that the only node that may violate the heap property is the new i. (Why?)

Kind of like bubblesort or insertion sort in a tree. The last leaf value trickles up until it stops.

Running Time? (Maximum number of comparisons and swaps.)


next up previous
Next: Building a Heap from Up: HEAPS Previous: Down-Heapify