Comparisons are blue,
swaps are red.
…
Like Merge Sort, QuickSort is a Divide and Conquer algorithm. It picks an element as a pivot and partitions the given array around the selected pivot. There are many different versions of quickSort that selects a pivot in different ways.
The quick sort uses divide and conquer to gain the same advantages as the merge sort, while not using additional storage. As a trade-off, however, it is possible that the list may not be divided in half. When this happens, we will see that performance is diminished.
The algorithm was developed by a British computer scientist Tony Hoare in 1959. The name "Quick Sort" comes from the fact that a quick sort can sort a list of data elements significantly faster (twice or thrice faster) than any of the common sorting algorithms. It is one of the most efficient sorting algorithms and is based on splitting an array (partition) into smaller ones and swapping (exchange) based on the comparison with the 'pivot' element selected.
It's important to remember that Quicksort isn't a stable algorithm. A stable sorting algorithm is an algorithm where the elements with the same values appear in the same order in the sorted output as they appear in the input list.
A computer will do what you tell it to do, but that may be much different from what you had in mind.
…