next up previous
Next: Up: Previous:

Analysis



There are O(n) calls to Heapify, thus BuildHeap is O(nlgn), which is an upper bound but not a tight bound (o(nlgn)).

The tight upper bound is O(nh).

Notice that the height h changes as the heap is being built.



Note: There can be at most $\lceil n/2^{h+1} \rceil$ nodes of height h in an n-element heap.

Thus Heapify = O(h) for nodes of height h.


next up previous
Next: Up: Previous: