Penguin

A sorting Algorithm.

Quicksort is a "divide and conquer" algorithm that works by taking an array, breaking it into two points around a 'pivot' item, and quicksorting both the smaller arrays. On average it needs O(n log(n)) comparisons to sort n items, but in the worst case requires O(n2) comparisons.

The tricky point is deciding which element to use as the pivot.

There is an excellent write up, with psuedocode at WikiPedia:Quicksort.


CategoryAlgorithm