June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,20 @@
shellsort := proc(arr)
local n, gap, i, val, j;
n := numelems(arr):
gap := trunc(n/2):
while (gap > 0) do #notice by 1 error
for i from gap to n by 1 do
val := arr[i];
j := i;
while (j > gap and arr[j-gap] > val) do
arr[j] := arr[j-gap];
j -= gap;
end do;
arr[j] := val;
end do;
gap := trunc(gap/2);
end do;
end proc;
arr := Array([17,3,72,0,36,2,3,8,40,0]);
shellsort(arr);
arr;