7. Priority Queue HEAP-EXTRACT-MAX(A) if heap-size[A] < 1 then error “heap underflow” max A[1] A[1] A[heap-size[A]] heap-size[A] heap-size[A]-1 MAX-HEAPIFY(A,1) return max
8. Priority Queue HEAP-INCREASE-KEY(A, i, key) if key < A[i] then error “new key is smaller than current key” A[i] key while i > 1 and A[PARENT(i)] < A[i] do exchange A[i] A[PARENT(i)] i PARENT(i)
14. Quick Sort Divide: Partition the array into two sub-arrays A[p . . q-1] and A[q+1 . . r] such that each element of A[p . . q-1] is less than or equal to A[q], which in turn less than or equal to each element of A[q+1 . . r]
15. Quick Sort Conquer: Sort the two sub-arrays A[p . . q-1] and A[q+1 . . r] by recursive calls to quick sort.
16. Quick Sort Combine: Since the sub-arrays are sorted in place, no work is needed to combine them.
17. Quick Sort QUICKSORT(A, p, r) if p< r then q PARTITION(A, p, r) QUICKSORT(A, p, q-1) QUICKSORT(A, q+1, r)