资 源 简 介
```py
RANDOMIZED_PARTITION(A, p ,r)
i = RANDOM(p,r) #1
exchange A[r] & A[i] #2
return PARTITION(A, p , r) #3
```
```py
PARTITION(A, p, r)
x = A[r] #1
i = p - 1 #2
for j= (p, r-1) #3
if A[j]<=x #4
i = i + 1 #5
exchange A[i] & A[j] #6
exchange A[i+1] & A[r] #7
return i+1 #8
```
Each time the `PARTITION` procedure is called, it selects a **pivot element*