Analysis of the Heap Operation
Insert - O(log n) worst case.
- Each percolate up goes up at most log n levels.
- Often O(1) in practice because keys do not percolate far.
Delete-Max - O(log n) worst case.
- Percolates down tend to go close to the leaves of the heap.