** Quicksort Performance**

Quicksort usually performs quite well; we want to avoid the *O(n ^{2})*
worst case and keep it at

The choice of pivot is important; choosing the first element is a very bad choice if the array is almost sorted. Choosing the median of the first, middle, and last elements makes it very unlikely that we will get a bad choice.

IntroSort (``introspective sort'') changes from Quicksort to a different sort for some cases:

- Change to Insertion Sort when the size becomes small (
*≤ 20*), where Insertion Sort may be more efficient. - Change to Heapsort after a certain depth of recursion, which
can protect against the unusual
*O(n*worst case.^{2})

Quicksort is easily parallelized, and no synchronization is required: each subarray can be sorted independently.