Since the runtime of Quicksort can be slow () if the array is already sorted or nearly sorted, we want to randomize the pivot element.

Runtime

Average

How does it work?

The function is identical to Quicksort, but the difference is that we now use the function Randomized Partition.