Quick Sort

About

It's a Divide and Conquer algorithm. It takes a pivot value that usually is in the middle of the DS, and sorts every value smaller or equal than the pivot to it's left and every value greater to the right.

After this, you take a new pivot for each of the new sections, and do it again, and on and on... until reaching the base case of a section of size 0 or 1.

circle-info

It should do the sorting inplace, instead of creating temporary structures to hold these middle arrays.

Drawing
circle-info

Asymptotically QuickSort can be O(N logN)O(N\ log N) or O(N2)O(N²) depending on how you pick your pivots.

The literal wort case scenario would be having a reverse ordered Array and picking the last element as the pivot.

Implementation on Arrays

Last updated