1procedure insert(heap, value)
2 append value to end of heap
3 i ← heap.size - 1
4 while i > 0 and heap[i] < heap[parent(i)]
5 swap heap[i] and heap[parent(i)]
6 i ← parent(i)
7procedure extractMin(heap)
8 min ← heap[0]
9 heap[0] ← heap[last]
10 remove last element
11 siftDown(heap, 0)
12 return min