42F. The Cost of Heap Operations

A min-heap whose bottom level is at depth d can have up to 2d+1−1 nodes. For example, if levels 0, 1 and 2 are full then there are 7 = 23−1 nodes.

By the structural requirement, if the bottom level has depth d then levels 1, …, d−1 must be full, and they hold exactly 2d−1 nodes. Since the bottom level must have at least one node in it, if a particular heap has n nodes and its bottom level has depth d, it must be the case that

n ≥ 2d

Taking logs (base 2) of both sides, and relying on the fact that the log function is monotonically increasing,

log(n) ≥ d

The time required for insertion and deletion are dominated by the time required to do the reheapUp or reheapDown operations, whose cost is, in the worst case, proportional to the total depth. So insertion and deletion are both done in time Θ(log(n)).