Compare sorting algorithms' performance: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: changed an arrow glyph.) |
(→{{header|REXX}}: added an exchange sort to the sorts being compared.) |
||
Line 2,475: | Line 2,475: | ||
call set@; call time 'R'; call cocktailSB #; cocktailSB.ra.ki= format(time("E"),,2) |
call set@; call time 'R'; call cocktailSB #; cocktailSB.ra.ki= format(time("E"),,2) |
||
call set@; call time 'R'; call comb #; comb.ra.ki= format(time("E"),,2) |
call set@; call time 'R'; call comb #; comb.ra.ki= format(time("E"),,2) |
||
call set@; call time 'R'; call exchange #; exchange.ra.ki= format(time("E"),,2) |
|||
call set@; call time 'R'; call gnome #; gnome.ra.ki= format(time("E"),,2) |
call set@; call time 'R'; call gnome #; gnome.ra.ki= format(time("E"),,2) |
||
call set@; call time 'R'; call heap #; heap.ra.ki= format(time("E"),,2) |
call set@; call time 'R'; call heap #; heap.ra.ki= format(time("E"),,2) |
||
Line 2,499: | Line 2,500: | ||
call show 'cocktailSB' /*+Shifting Bounds*/ /* ◄──── " " " cocktailSB " */ |
call show 'cocktailSB' /*+Shifting Bounds*/ /* ◄──── " " " cocktailSB " */ |
||
call show 'comb' /* ◄──── " " " comb " */ |
call show 'comb' /* ◄──── " " " comb " */ |
||
call show 'exchange' /* ◄──── " " " exchange " */ |
|||
call show 'gnome' /* ◄──── " " " gnome " */ |
call show 'gnome' /* ◄──── " " " gnome " */ |
||
call show 'heap' /* ◄──── " " " heap " */ |
call show 'heap' /* ◄──── " " " heap " */ |
||
Line 2,572: | Line 2,574: | ||
end /*j*/ /* [↑] swap two elements in the array.*/ |
end /*j*/ /* [↑] swap two elements in the array.*/ |
||
end /*until*/; return |
end /*until*/; return |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
|||
exchange: procedure expose @.; parse arg n 1 h /*both N and H have the array size.*/ |
|||
do while h>1; h= h % 2 |
|||
do i=1 for n-h; j= i; k= h+i |
|||
do while @.k<@.j |
|||
_= @.j; @.j= @.k; @.k= _; if h>=j then leave; j= j-h; k= k-h |
|||
end /*while @.k<@.j*/ |
|||
end /*i*/ |
|||
end /*while h>1*/; return |
|||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
gnome: procedure expose @.; parse arg n; k= 2 /*N: is number items. */ |
gnome: procedure expose @.; parse arg n; k= 2 /*N: is number items. */ |
||
Line 2,733: | Line 2,744: | ||
sort type │ allONES ascend random │ allONES ascend random │ allONES ascend random │ allONES ascend random │ allONES ascend random │ |
sort type │ allONES ascend random │ allONES ascend random │ allONES ascend random │ allONES ascend random │ allONES ascend random │ |
||
────────────┼─────────────────────────┼─────────────────────────┼─────────────────────────┼─────────────────────────┼─────────────────────────┤ |
────────────┼─────────────────────────┼─────────────────────────┼─────────────────────────┼─────────────────────────┼─────────────────────────┤ |
||
bubble │ 0.00 0.00 0.06 │ 0. |
bubble │ 0.00 0.00 0.06 │ 0.00 0.00 0.28 │ 0.00 0.00 1.11 │ 0.00 0.02 4.39 │ 0.00 0.00 17.53 │ |
||
cocktail │ 0.00 0.00 0.08 │ 0.00 0.02 0.27 │ 0.00 0. |
cocktail │ 0.00 0.00 0.08 │ 0.00 0.02 0.27 │ 0.00 0.02 1.13 │ 0.00 0.00 4.75 │ 0.00 0.00 18.19 │ |
||
cocktailSB │ 0.00 0.00 0.05 │ 0. |
cocktailSB │ 0.00 0.00 0.05 │ 0.02 0.00 0.22 │ 0.00 0.00 0.91 │ 0.02 0.00 3.59 │ 0.02 0.02 14.16 │ |
||
comb │ 0. |
comb │ 0.02 0.00 0.02 │ 0.00 0.00 0.02 │ 0.03 0.03 0.03 │ 0.06 0.06 0.08 │ 0.14 0.14 0.20 │ |
||
exchange │ 0.00 0.00 0.00 │ 0.02 0.02 0.02 │ 0.02 0.00 0.05 │ 0.03 0.02 0.08 │ 0.06 0.05 0.20 │ |
|||
gnome │ 0.00 0.06 0.06 │ 0.00 0.11 0.24 │ 0.00 0.16 0.86 │ 0.00 3.50 3.61 │ 0.02 8.95 14.08 │ |
|||
heap │ 0.00 0.00 0.00 │ 0.02 0.02 0.02 │ 0.03 0.06 0.05 │ 0.05 0.11 0.11 │ 0.08 0.25 0.25 │ |
|||
insertion │ 0.00 0.00 0.03 │ 0.00 0.02 0.13 │ 0.00 0.00 0.47 │ 0.02 0.02 1.88 │ 0.02 0.02 7.84 │ |
|||
merge │ 0.02 0.02 0.02 │ 0.00 0.00 0.02 │ 0.03 0.03 0.03 │ 0.05 0.05 0.08 │ 0.11 0.13 0.17 │ |
|||
pancake │ 0.00 0.00 0.08 │ 0.02 0.00 0.30 │ 0.00 0.00 1.20 │ 0.02 0.02 4.73 │ 0.02 0.00 19.63 │ |
|||
quick │ 0.00 0.00 0.00 │ 0.00 0.00 0.00 │ 0.00 0.00 0.02 │ 0.00 0.00 0.05 │ 0.00 0.00 0.09 │ |
|||
radix │ 0.00 0.00 0.00 │ 0.00 0.03 0.03 │ 0.02 0.03 0.05 │ 0.05 0.08 0.08 │ 0.09 0.14 0.14 │ |
|||
selection │ 0.02 0.03 0.03 │ 0.09 0.08 0.08 │ 0.33 0.33 0.38 │ 1.22 1.39 1.55 │ 4.95 4.86 5.30 │ |
|||
shell │ 0.02 0.00 0.00 │ 0.00 0.00 0.02 │ 0.02 0.02 0.05 │ 0.05 0.05 0.09 │ 0.13 0.11 0.22 │ |
|||
────────────┴─────────────────────────┴─────────────────────────┴─────────────────────────┴─────────────────────────┴─────────────────────────┘ |
────────────┴─────────────────────────┴─────────────────────────┴─────────────────────────┴─────────────────────────┴─────────────────────────┘ |
||
</pre> |
</pre> |