1procedure merge(h1, h2)
2 if h1 is null, return h2 (and vice versa)
3 ensure h1.key ≤ h2.key (swap if needed)
4 h1.right ← merge(h1.right, h2)
5 if rank(h1.left) < rank(h1.right)
6 swap h1.left and h1.right
7 h1.rank ← rank(h1.right) + 1
8 return h1
9procedure insert(heap, value)
10 return merge(heap, new node(value))
11procedure extractMin(heap)
12 min ← heap.key
13 return merge(heap.left, heap.right)