next up previous
Next: Analysis Up: CSE 2320: Algorithms and Previous: BuildHeap

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 = for nodes of height h.



Copyright © 1998 The University of Texas at Arlington