Compare sorting algorithms' performance: Difference between revisions

→‎{{header|REXX}}: added an exchange sort to the sorts being compared.
m (→‎{{header|REXX}}: changed an arrow glyph.)
(→‎{{header|REXX}}: added an exchange sort to the sorts being compared.)
Line 2,475:
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 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 heap #; heap.ra.ki= format(time("E"),,2)
Line 2,499 ⟶ 2,500:
call show 'cocktailSB' /*+Shifting Bounds*/ /* ◄──── " " " cocktailSB " */
call show 'comb' /* ◄──── " " " comb " */
call show 'exchange' /* ◄──── " " " exchange " */
call show 'gnome' /* ◄──── " " " gnome " */
call show 'heap' /* ◄──── " " " heap " */
Line 2,572 ⟶ 2,574:
end /*j*/ /* [↑] swap two elements in the array.*/
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. */
Line 2,733 ⟶ 2,744:
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.0200 0.00 0.2728 │ 0.00 0.00 1.0511 │ 0.00 0.0002 4.3039 │ 0.00 0.0200 17.7853
cocktail │ 0.00 0.00 0.08 │ 0.00 0.02 0.27 │ 0.00 0.0002 1.0513 │ 0.0200 0.00 4.2775 │ 0.0200 0.00 1718.8619
cocktailSB │ 0.00 0.00 0.05 │ 0.0002 0.00 0.22 │ 0.00 0.00 0.8891 │ 0.0002 0.0200 3.4759 │ 0.0002 0.02 14.1716
comb │ 0.0002 0.0200 0.02 │ 0.00 0.00 0.02 │ 0.03 0.03 0.03 │ 0.06 0.06 0.0908 │ 0.1614 0.1614 0.20 │
gnome exchange │ 0.00 0.0500 0.0500 │ 0.0002 0.1102 0.2202 │ 0.0002 0.1600 0.8605 │ 0.0203 30.4102 30.4708 │ 0.0206 80.7005 14 0.3420
heap gnome │ 0.0200 0.0206 0.0206 │ 0.00 0.0311 0.0324 │ 0.0300 0.0616 0.0586 │ 0.0300 03.1150 03.1361 │ 0.0902 08.2595 014.2308
insertionheap │ 0.00 0.00 0.0300 │ 0.0002 0.0002 0.1102 │ 0.0003 0.0006 0.4705 │ 0.0005 0.0011 10.8311 │ 0.0208 0.0225 70.5225
merge insertion │ 0.00 0.00 0.0003 │ 0.0200 0.02 0.0213 │ 0.0300 0.0300 0.0347 │ 0.0602 0.0502 01.0988 │ 0.1102 0.1102 07.1984
pancakemerge │ 0.0002 0.0002 0.0802 │ 0.00 0.00 0.3002 │ 0.0003 0.0003 10.1703 │ 0.0005 0.0005 40.6908 │ 0.0011 0.0213 19 0.2217
quick pancake │ 0.00 0.00 0.0008 │ 0.0002 0.00 0.0030 │ 0.00 0.00 01.0220 │ 0.0002 0.02 04.0573 │ 0.02 0.00 019.0963
radixquick │ 0.0200 0.0200 0.0200 │ 0.0200 0.0200 0.0200 │ 0.0300 0.0300 0.0302 │ 0.0500 0.0600 0.0805 │ 0.0900 0.1300 0.1409
selectionradix │ 0.0200 0.0200 0.0200 │ 0.0800 0.0803 0.0903 │ 0.2802 0.3103 0.340510.2505 10.3008 10.470840.9509 40.7714 50.3414
shell selection │ 0.0002 0.0003 0.0003 │ 0.0009 0.0008 0.0208 │ 0.0333 0.0233 0.053801.0622 01.0539 01.085504.1395 04.1186 05.2030
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>