[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
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.



last edited (November 6, 2006) by bilderbikkel, Number of views: 7689, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Site Management by Lars Hagelin at Kontantkort.se.