To insert an element:
Add it at the end of the array (next position in the complete tree).
"Bubble up": while it's smaller than its parent (in a min-heap), swap with parent.
Stop when heap property is restored.
function insert(heap, value)
append value to heap
i := length of heap - 1
while i > 0 and heap[i] < heap[parent(i)]
swap heap[i] and heap[parent(i)]
i := parent(i)
At most swaps, one per level.