Random-Partition(A, p, r) i = Random(p, r) swap(A[p], A[i]) return(Partition(A, p, r))

Random-Select(A, p, r, i) replace Partition with Random-Partition replace Select with Random-Select

These are still
in the worst case

and O(n) in the average case.

However, we can get O(n) worst case performance with Select2.