|
First call: QuickSort (Data, 0, Count-1)
Left
Check if at least two values have to be sorted
PivotIndex := Partition (Data, Left, Right)
The right element will be used as pivot element. The function reorders the list so that all elements which are less than the pivot element come before the pivot element and so that all elements greater than the pivot element come after it (equal values can go either way). After this partitioning, the pivot is in its final position. The return value is the new position of the pivot element.
QuickSort (Data, Left, PivotIndex - 1)
Sort all Data left of the pivot element.
QuickSort (Data, PivotIndex + 1, Right)
Sort all Data right of the pivot element
i := Left
Counter from the left hand side
j := Right - 1
Counter from the right hand side
Pivot := Data [Right]
Value of the pivot element. After sorting has finished, all values less than the pivot element are on his left hand side and all values greater than the pivot element are on his right hand side.
Data [i] <= Pivot and i < Right
Search a wrong sorted value on the left hand side of the pivot element
Data [j] >= Pivot and j > Left
Search a wrong sorted value on the right hand side of the pivot element
i < j
Are there any values remaining which have to be sorted
Swap Data [i] and Data [j]
Swap the wrong sorted values
Swap Data [i] and Data [Right]
Copy the pivot element on his correct position
End Return value: i
| Page Views | |
| Visitors today | |
| Average visitors per day | |
| Visitors since | |


