[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
QuickSort
It has the advantage of being faster than the bubble sort but the disadvantage of being more difficult to code.
The crux of the quick sort algorithm is to select a certain element which will serve as the "pivot" point of the algorithm, then sweep all other elements, placing those which are less than the value of the pivot to the left and those which are greater than the value of the pivot to the right.
Thus, at the end of the first sweep, the pivot will be in its proper location within the array. The next step (which will thereafter be applied recursively) is to treat all numbers to the left of the pivot as a smaller array, and all numbers to the right of the pivot as a smaller array.
The quick sort is then applied to each of these two sub-arrays (that is, within each sub-array, a new pivot is selected and the other elements are positioned around it).
The recursion stops once a one- or no-element array has been reached.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
QuickSort
(Computer science) Quick Sort Algorithm
The '''quick sort algorithm''' is a sorting algorithm used to place elements of an array in order.It has the advantage of being faster than the bubble sort but the disadvantage of being more difficult to code.
The crux of the quick sort algorithm is to select a certain element which will serve as the "pivot" point of the algorithm, then sweep all other elements, placing those which are less than the value of the pivot to the left and those which are greater than the value of the pivot to the right.
Thus, at the end of the first sweep, the pivot will be in its proper location within the array. The next step (which will thereafter be applied recursively) is to treat all numbers to the left of the pivot as a smaller array, and all numbers to the right of the pivot as a smaller array.
The quick sort is then applied to each of these two sub-arrays (that is, within each sub-array, a new pivot is selected and the other elements are positioned around it).
The recursion stops once a one- or no-element array has been reached.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
