Jump to content

Sorting algorithms/Heapsort: Difference between revisions

m
→‎{{header|REXX}}: corrected a misspelling. -- ~~~~
mNo edit summary
m (→‎{{header|REXX}}: corrected a misspelling. -- ~~~~)
Line 1,872:
=={{header|REXX}}==
<lang rexx>/*REXX program sorts an array using the heapsort method. */
 
call gen@ /*generate array elements. */
call show@ 'before sort' /*show before array elements*/
Line 1,878 ⟶ 1,877:
call show@ ' after sort' /*show after array elements*/
exit
 
 
/*─────────────────────────────────────HEAPSORT subroutine─────────*/
heapSort: procedure expose @.; parse arg n
Line 1,892 ⟶ 1,889:
 
return
 
 
/*─────────────────────────────────────SHUFFLE subroutine──────────*/
shuffle: procedure expose @.; parse arg i,n; _=@.i
Line 1,906 ⟶ 1,901:
@.i=_
return
 
 
/*─────────────────────────────────────GEN@ subroutine─────────────*/
gen@: @.='' /*assign default value. */
 
@.1 ='---letters of the modern Greek Alphabet---'
@.2 ='=========================================='
Line 1,943 ⟶ 1,935:
highItem=highItem-1 /*adjust highItem slightly. */
return
 
 
/*─────────────────────────────────────SHOW@ subroutine────────────*/
show@: widthH=length(highItem) /*maximum width of any line.*/
Line 1,952 ⟶ 1,942:
end
 
say copies('─',80) /*show a seperatorseparator line. */
return</lang>
{{out}}
Cookies help us deliver our services. By using our services, you agree to our use of cookies.