Jump to content

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 shuffle heapSuff 1, n-1
end /*n*/; return /* [↑] swap two elements; and shuffle.*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
shuffleheapSuff: procedure expose @.; parse arg i,n; $= @.i /*obtain parent.*/
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
Cookies help us deliver our services. By using our services, you agree to our use of cookies.