Sorting algorithms/Comb sort: Difference between revisions

m
Line 225:
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. */
gapput =skip data (gap / 1.25);
gap = gap / 1.25e0;
put skip data (gap);
swaps = '1'b;
/* a single "comb" over the array. */
do i = 0lbound(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;
Anonymous user