Building a heap
Turn a whole row into a heap at once, every number at least as big as its children. The numbers with no children are heaps of one already. Sift each parent down, from the last back to the first, and the parts below it are always heaps by then.
the row
the row as a tree
- comparisons
- 0
- swaps
- 0
step 1 of 1
Examples