Anonymous user
Sorting Algorithms/Circle Sort: Difference between revisions
m
→{{header|REXX}}: elided useless testing statement.
(→{{header|REXX}}: simplified the REXX program by using a SWAP subroutine.) |
m (→{{header|REXX}}: elided useless testing statement.) |
||
Line 308:
do i=1 for #; @.i=word(x,i); end /*assign numbers to the array @.*/
/*array indices are easier to use*/
call circleSort
y=@.1 /*start with the first element. */
do j=2 to #; y=y @.j; end /*assign array numbers to a list.*/
Line 315:
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────CIRCLESORT subroutine───────────────*/
circleSort: procedure expose @.; parse arg
return /*circleSort is done*/
/*──────────────────────────────────.CIRCLESRT subroutine───────────────*/
.circleSrt: procedure expose @.; parse arg lo,hi,swaps /*get the args. */
if lo==hi then return swaps /*are we done ? */
high=hi; low=lo; mid=(hi-lo) % 2 /*assign indices*/
Line 329 ⟶ 327:
lo=lo+1; hi=hi-1 /*add; subtract.*/
end /*while lo<hi*/ /*just 1 section*/
if lo==hi then if @.lo>@.
swaps=.circleSrt(low,
swaps=.circleSrt(low+mid+1, high,
return swaps /*section done. */
/*──────────────────────────────────.SWAP subroutine────────────────────*/
|