Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,35 @@
|
|||
const proc: quickSort (inout array elemType: arr, in integer: left, in integer: right) is func
|
||||
local
|
||||
var elemType: compare_elem is elemType.value;
|
||||
var integer: less_idx is 0;
|
||||
var integer: greater_idx is 0;
|
||||
var elemType: help is elemType.value;
|
||||
begin
|
||||
if right > left then
|
||||
compare_elem := arr[right];
|
||||
less_idx := pred(left);
|
||||
greater_idx := right;
|
||||
repeat
|
||||
repeat
|
||||
incr(less_idx);
|
||||
until arr[less_idx] >= compare_elem;
|
||||
repeat
|
||||
decr(greater_idx);
|
||||
until arr[greater_idx] <= compare_elem or greater_idx = left;
|
||||
if less_idx < greater_idx then
|
||||
help := arr[less_idx];
|
||||
arr[less_idx] := arr[greater_idx];
|
||||
arr[greater_idx] := help;
|
||||
end if;
|
||||
until less_idx >= greater_idx;
|
||||
arr[right] := arr[less_idx];
|
||||
arr[less_idx] := compare_elem;
|
||||
quickSort(arr, left, pred(less_idx));
|
||||
quickSort(arr, succ(less_idx), right);
|
||||
end if;
|
||||
end func;
|
||||
|
||||
const proc: quickSort (inout array elemType: arr) is func
|
||||
begin
|
||||
quickSort(arr, 1, length(arr));
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue