Overview of Quicksort
We'll cover the following...
Like merge sort, quicksort uses divide-and-conquer, and so it's a recursive algorithm. The way that quicksort uses divide-and-conquer is a little different from how merge sort does. In merge sort, the divide step does hardly anything, and all the real work happens in the combine step. Quicksort is the opposite: all the real work happens in the divide step. In fact, the combine step in quicksort does absolutely nothing.
Quicksort has a couple of other differences from merge sort. Quicksort works in place. And its worst-case running time is as bad as selection sort's and insertion sort's:
Here is how quicksort uses divide-and-conquer. As with merge sort, think of sorting a subarray
Divide by choosing any element in the subarray
. Call this element the pivot. Rearrange the elements in so that all other elements in ...