Есть алгоритм QuickSort написанный на псевдокоде:
procedure QuickSort(Low,High)
PivotIndex FindPivot(Low,High)
if PivotIndex not equal 0
then Pivot = Key[MinIndex]
if Low < High then
i = Low - 1 {i scans from the left to find elements ≥ the pivot
j = High + 1 {j scans from the right to find elements ≤ the pivot
while i < j do
i = i + 1
while i ≤ High and Key[i] < Pivot do
i = i + 1
endwhile
j = j - 1
while j ≥ Low and Key[j] > Pivot do
j = j - 1
endwhile
if i ≤ High then Key[i] ↔ Key[j] endif
endwhile
if i ≤ High then Key[i] ↔ Key[j] endif { undo extra swap
Key[j] ↔ Key[PivotIndex] { move the pivot into its proper position
QuickSort(Low,j - 1)
QuickSort(j + 1,High)
endif
endif
end {QuickSort
При этом Pivot это крайний левый элемент из списка элементов которые нужно отсортировать.
Пожалуйста, помогите правильно переписать процедуру в Pascal.
<<<Зарание спасибо за внимание>>>