## BuildHeap(): build heap bottom-up by running Heapify() on successive subarrays

- Walk backwards through the array from n/2 to 1, calling Heapify() on each node.
- Order of processing guarantees that the children of node i are heaps when i is processed

## Easy to show that running time is O(n lg n)

## Can be shown to be O(n)

- Key observation: most subheaps are small

Previous slide | Next slide | Back to first slide | View graphic version |