To extract the minimum (in a min-heap):
Save the root value.
Move the last element to the root.
"Bubble down": while larger than a child, swap with the smaller child.
Return the saved value.
function extractMin(heap)
minVal := heap[0]
heap[0] := last element of heap
remove last element
bubbleDown(heap, 0)
return minVal
Bubbling down takes at most swaps.