Randomized Quicksort

Two ways to implement randomized Quicksort,

Method 1: random code selection

Method2: Generate a random permutation of the input and feed it into the operational sort, which selects the first element as the axis of rotation

Is method 1 the same as method2 in terms of randomization?

Note. Method2 seems to generate all partitions the same way, but method1 does not work. Therefore, if they do not match, I want to understand what is the impact on performance.

+5
source share
1 answer

. , , 1/Len (). ( , .)

+2

All Articles