18 views
PARTITION(A,p,r)

1    x = A[r]
2    i = p – 1
3    for j = p to r – 1
4    if A[j] <= x
5    i = i + 1
6    exchange A[i] with A[j]
7    exchange A[i+1] with A[r]
8    return i + 1

illustrate the operation of PARTITION on the array $A=\langle 13,19,9,5,12,8,7,4,21,2,6,11\rangle$

| 18 views