Sorting algorithms/Shell sort: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added whitespace, changed some comments.) |
m (→{{header|REXX}}: changed a variable name, changed DO-end comments.) |
||
Line 2,789: | Line 2,789: | ||
return |
return |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
shellSort: procedure expose @.; parse arg |
shellSort: procedure expose @.; parse arg n /*obtain the n from the argument list*/ |
||
i= |
i= n % 2 /*% is integer division in REXX. */ |
||
do while i\==0 |
do while i\==0 |
||
do j=i+1 to |
do j=i+1 to n; k= j; p= k - i /*P: previous item*/ |
||
_= @.j |
_= @.j |
||
do while k>=i+1 & @.p>_; @.k= @.p; k= k-i; p= k-i |
do while k>=i+1 & @.p>_; @.k= @.p; k= k-i; p= k-i |
||
end /*while |
end /*while*/ |
||
@.k= _ |
@.k= _ |
||
end /*j*/ |
end /*j*/ |
||
if i==2 then i= 1 |
if i==2 then i= 1 |
||
else i= i * 5 % 11 |
else i= i * 5 % 11 |
||
end |
end /*while*/ |
||
return |
return |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |