Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -1,23 +1,23 @@
|
|||
swap := proc(arr, a, b)
|
||||
local temp := arr[a];
|
||||
arr[a] := arr[b];
|
||||
arr[b] := temp;
|
||||
local temp := arr[a];
|
||||
arr[a] := arr[b];
|
||||
arr[b] := temp;
|
||||
end proc:
|
||||
|
||||
stoogesort:= proc(arr, start_index, end_index)
|
||||
local cur;
|
||||
if (arr[end_index] < arr[start_index]) then
|
||||
swap(arr, start_index, end_index);
|
||||
end if;
|
||||
|
||||
if end_index - start_index > 1 then
|
||||
cur := trunc((end_index - start_index + 1)/3);
|
||||
stoogesort(arr, start_index, end_index - cur);
|
||||
stoogesort(arr, start_index + cur, end_index);
|
||||
stoogesort(arr, start_index, end_index - cur);
|
||||
end if;
|
||||
|
||||
return arr;
|
||||
local cur;
|
||||
if (arr[end_index] < arr[start_index]) then
|
||||
swap(arr, start_index, end_index);
|
||||
end if;
|
||||
|
||||
if end_index - start_index > 1 then
|
||||
cur := trunc((end_index - start_index + 1)/3);
|
||||
stoogesort(arr, start_index, end_index - cur);
|
||||
stoogesort(arr, start_index + cur, end_index);
|
||||
stoogesort(arr, start_index, end_index - cur);
|
||||
end if;
|
||||
|
||||
return arr;
|
||||
end proc:
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue