Anonymous user
Sorting algorithms/Heapsort: Difference between revisions
m
→{{header|REXX}}: changed subroutine names (which signifies ownership).
(Sorting algorithms/Heapsort en True BASIC) |
m (→{{header|REXX}}: changed subroutine names (which signifies ownership).) |
||
Line 4,313:
/*──────────────────────────────────────────────────────────────────────────────────────*/
heapSort: procedure expose @.; arg n; do j=n%2 by -1 to 1; call shuffle j,n; end /*j*/
do n=n by -1 to 2; _= @.1; @.1= @.n; @.n= _; call
end /*n*/; return /* [↑] swap two elements; and shuffle.*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
do while i+i<=n; j= i+i; k= j+1; if k<=n then if @.k>@.j then j= k
if $>=@.j then leave; @.i= @.j; i= j
|