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: mergeSort2 (inout array elemType: arr, in integer: lo, in integer: hi, inout array elemType: scratch) is func
|
||||
local
|
||||
var integer: mid is 0;
|
||||
var integer: k is 0;
|
||||
var integer: t_lo is 0;
|
||||
var integer: t_hi is 0;
|
||||
begin
|
||||
if lo < hi then
|
||||
mid := (lo + hi) div 2;
|
||||
mergeSort2(arr, lo, mid, scratch);
|
||||
mergeSort2(arr, succ(mid), hi, scratch);
|
||||
t_lo := lo;
|
||||
t_hi := succ(mid);
|
||||
for k range lo to hi do
|
||||
if t_lo <= mid and (t_hi > hi or arr[t_lo] <= arr[t_hi]) then
|
||||
scratch[k] := arr[t_lo];
|
||||
incr(t_lo);
|
||||
else
|
||||
scratch[k] := arr[t_hi];
|
||||
incr(t_hi);
|
||||
end if;
|
||||
end for;
|
||||
for k range lo to hi do
|
||||
arr[k] := scratch[k];
|
||||
end for;
|
||||
end if;
|
||||
end func;
|
||||
|
||||
const proc: mergeSort2 (inout array elemType: arr) is func
|
||||
local
|
||||
var array elemType: scratch is 0 times elemType.value;
|
||||
begin
|
||||
scratch := length(arr) times elemType.value;
|
||||
mergeSort2(arr, 1, length(arr), scratch);
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue