Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,25 @@
|
|||
/* From the pseudocode. */
|
||||
comb_sort: procedure (A);
|
||||
declare A(*) fixed;
|
||||
declare t fixed;
|
||||
declare (i, gap) fixed binary (31);
|
||||
declare swaps bit (1) aligned;
|
||||
|
||||
gap = hbound(A,1) - lbound(A,1); /* initialize the gap size. */
|
||||
do until (gap <= 1 & swaps);
|
||||
/* update the gap value for a next comb. */
|
||||
put skip data (gap);
|
||||
gap = gap / 1.25e0;
|
||||
put skip data (gap);
|
||||
swaps = '1'b;
|
||||
/* a single "comb" over the array. */
|
||||
do i = lbound(A,1) by 1 until (i + gap >= hbound(A,1));
|
||||
if A(i) > A(i+gap) then
|
||||
do;
|
||||
t = A(i); A(i) = A(i+gap); A(i+gap) = t;
|
||||
swaps = '0'b; /* Flag a swap has occurred, so */
|
||||
/* the list is not guaranteed sorted. */
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end comb_sort;
|
||||
Loading…
Add table
Add a link
Reference in a new issue