Quick Sort Program
Quick sort works as follows.
-
In each step of quick sort a range of an array is sorted.
-
The first element in the range is used as the pivot value.
-
The rest of the values in the range are grouped into two partitions:
one containing the values larger than the pivot value
and the other containing the values smaller than the pivot value.
-
Each of the partions is sorted by a recursive call of quick sort.
-
The partitioning of a range of values proceeds as follows.
-
The index lowIdx is used to find
a value that cannot be included in the partition of smaller values.
-
The index highIdx is used to find
a value that cannot be included in the partition of larger values.
-
The value that cannot be included in the partition of smaller values
and the value that cannot be included in the partition of larger values
are exchanged.
-
The above two steps are repeated until all the values in the range
are divided into the two partitions.
-
Finally, the pivot value is moved between the two partitions.
Source Code of the QuickSort Program
Source Code of the QuickSortG Program
(Graphical Version)
Back
Home