October 2004
Intermediate to advanced
336 pages
6h 27m
English
This function implements the quicksort algorithm.
Quicksort works by choosing an arbitrary element in the array and then dividing the array into two parts: The first part contains all elements less than or equal to the chosen element, and the second part contains all elements greater than the chosen element. The chosen element is then swapped into the spot between the two parts (known as the pivot point), which is its proper spot in the ultimately sorted array. The function is then called recursively twice—once on each part—to complete the sort.
Assume that the stack is deep enough that recursion will not cause a stack overflow when ...
Read now
Unlock full access