Compare sorting algorithms' performance: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: recoded/reformated the SHELL sort subroutine to use less whitespace.) |
m (→{{header|REXX}}: added wording to the REXX section header, allowd the starting number (of elements) to be specified on the command line.) |
||
Line 2,462: | Line 2,462: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
One goal for this REXX program was to include as many different sorts (that sorted arrays and not lists). |
|||
Because of the disparencies of some sorting algorithms, the range of numbers was chosen to be '''5''' so that the |
|||
<br>slower sorts wouldn't consume a lot of time trying to sort larger arrays. |
|||
The number of ranges can be increased at the expense of a wider display of output. |
|||
<lang rexx>/*REXX pgm compares various sorts for 3 types of input sequences: ones/ascending/random.*/ |
<lang rexx>/*REXX pgm compares various sorts for 3 types of input sequences: ones/ascending/random.*/ |
||
parse arg ranges seed . |
parse arg ranges start# seed . /*obtain optional arguments from the CL*/ |
||
if ranges=='' | ranges=="," then ranges= 5 /*Not Specified |
if ranges=='' | ranges=="," then ranges= 5 /*Not Specified? Then use the default.*/ |
||
if start#=='' | start#=="," then start#= 250 /* " " " " " " */ |
|||
if seed=='' | seed=="," then seed= 1946 /*use a repeatable seed for RANDOM BIF*/ |
if seed=='' | seed=="," then seed= 1946 /*use a repeatable seed for RANDOM BIF*/ |
||
if datatype(seed, 'W') then call random ,,seed /*Specified? Then use as a RANDOM seed*/ |
if datatype(seed, 'W') then call random ,,seed /*Specified? Then use as a RANDOM seed*/ |
||
kinds= 3; |
kinds= 3; hdr=; #= start# /*hardcoded/fixed number of datum kinds*/ |
||
do ra=1 for ranges |
|||
hdr= hdr || center( commas(#) "numbers", 25)'│' /*(top) header for the output title.*/ |
hdr= hdr || center( commas(#) "numbers", 25)'│' /*(top) header for the output title.*/ |
||
do ki=1 for kinds |
do ki=1 for kinds |