What does random shuffling do for distribution in the input space? To understand this, consider the probability distribution P defined by the set S , where P not under our control. Create a probability distribution P' , applying a random random shuffle, over S to P In other words, every time we get a sample from P , we map it uniformly randomly into an element from S What can you say about this resulting distribution P' ?
P'(x) = summation over all elements s in S of P(s)*1/|S| = 1/|S|
Thus, P' is a uniform distribution over S Random shuffling gives us control over the distribution of input probabilities.
How does this relate to quicksort? Well, we know the average complexity of quicksort. This is calculated by the uniform probability distribution, and this is the property that we want to maintain on our input distribution, regardless of what it really is. To do this, we randomly shuffle our input array, ensuring that the distribution is not adversarial.
Pradhan
source share