Google Interview Question

How to choose pivot in quicksort

Interview Answers

Anonymous

Aug 30, 2010

In simple quicksort you use the first element as the pivot. In randomized quicksort, you pick an element at random and swap it to the beinning of the array.

1

Anonymous

Nov 16, 2010

median of 3: take first, middle and last element; choose median among these - ensures you never choose the smallest or largest element as your pivot (i.e., make progress on each quicksort iteration).