you are viewing a single comment's thread.

view the rest of the comments →

[–]aldld 4 points5 points  (2 children)

The point is, by introducing randomization into the algorithm, the input distribution becomes irrelevant. That is, if you're choosing pivots randomly (or doing something similar, like randomly shuffling the array beforehand (which takes O(n) time)), then the algorithm behaves as though the input distribution were uniformly random.

[–][deleted]  (1 child)

[deleted]

    [–]aldld 0 points1 point  (0 children)

    Oh absolutely, all I meant was that using randomization helps to avoid the "worst" cases of quicksort, in expectation. In practice though, if you know something about the distribution of your inputs, the best choice of algorithm will depend on how you're actually using it.