| Free tutorials for Java, Eclipse and Web programming |
Version 0.6
Copyright © 2009 -2010 Lars Vogel
06.08.2010
| Revision History | ||
|---|---|---|
| Revision 0.1 | 17.05.2009 | Lars Vogel |
| Created | ||
| Revision 0.2 - 0.6 | 06.08.2010 | Lars Vogel |
| bug fixes and enhancements | ||
Table of Contents
Sort algorithms are ordering the elements of an array according to a predefined order. Quicksort is a divide and conquer algorithm. In a divide and conquer sorting algorithm the the original data is separated into two parts (divide) which are individually sorted (conquered) and then combined.
If the array contains only one element or zero elements then the array is sorted.
If the array contains more then one element then:
Select an element from the array. This element is called the "pivot element". For example select the element in the middle of the array.
All elements which are smaller then the pivot element are placed in one array and all elements which are larger are placed in another array.
Sort both arrays by recursively applying Quicksort to them.
Combine the arrays
Quicksort can be implemented to sort "in-place". This means that the sorting takes place in the array and that no additional array need to be created.