Algorithm 1 Minimum Priority Queue

1:procedure HeapMinimum(AA)

2:return A[1]A[1]

3:end procedure

4:

5:procedure HeapExtractMin(AA)

6:if A.heap-size<1A.\text{heap-size} < 1 then

7:error "heap underflow"

8:end if

9:min=A[1]min = A[1]

10:A[1]=A[A.heap-size]A[1] = A[A.\text{heap-size}]

11:A.heap-size=A.heap-size1A.\text{heap-size} = A.\text{heap-size} - 1

12:MinHeapify(A,1A, 1)

13:return minmin

14:end procedure

15:

16:procedure HeapDecreaseKey(A,i,keyA, i, key)

17:if key>A[i]key > A[i] then

18:error "new key is larger than the current key"

19:end if

20:A[i]=keyA[i] = key

21:while i>1i > 1 and A[PARENT(i)]>A[i]A[PARENT(i)] > A[i] do

22:exchange A[i]A[i] with A[PARENT(i)]A[PARENT(i)]

23:i=PARENT(i)i = PARENT(i)

24:end while

25:end procedure

26:

27:procedure MinHeapInsert(A,keyA, key)

28:A.heap-size=A.heap-size+1A.\text{heap-size} = A.\text{heap-size} + 1

29:A[A.heap-size]=+A[A.\text{heap-size}] = +\infty

30:HeapDecreaseKey(A,A.heap-size,keyA, A.\text{heap-size}, key)

31:end procedure