Why does a heap with $n$ nodes have height $O(\log n)$?
Because every level above the bottom is full, the node count doubles from level to level: a heap of height h holds at least $2^h$ nodes. So $n \geq 2^h$, i.e. $h \leq \log_2 n$.
Count the nodes per depth in a heap of height h:
| Depth | Nodes |
|---|---|
| 0 | 1 |
| 1 | 2 |
| … | … |
| h − 1 | $2^{h-1}$ |
| h | between 1 and $2^h$ |
If all levels including the bottom one are full, the geometric sum gives $n = 1 + 2 + 4 + \dots + 2^h = 2^{h+1} - 1$, so $h = \log_2(n+1) - 1$, which is $O(\log n)$.
The general case follows the same way. The full levels 0 to h − 1 already hold $2^h - 1$ nodes, and the bottom level adds at least one more, so $n \geq 2^h$ and therefore $h \leq \log_2 n$. Exactly: $h = \lfloor \log_2 n \rfloor$.
This is the fact everything else rests on. Insertion and removal each repair the heap along a single root-to-leaf path, so their cost is bounded by the height. A million entries make a heap only about 20 levels deep.