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.02 0.00 0.27 │ 0.00 0.00 1.05 │ 0.00 0.00 4.30 │ 0.00 0.02 17.78
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.00 1.05 │ 0.02 0.00 4.27 │ 0.02 0.00 17.86
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.00 0.00 0.22 │ 0.00 0.00 0.88 │ 0.00 0.02 3.47 │ 0.00 0.02 14.17
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.00 0.02 0.02 │ 0.00 0.00 0.02 │ 0.03 0.03 0.03 │ 0.06 0.06 0.09 │ 0.16 0.16 0.20 │
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 │
gnome │ 0.00 0.05 0.05 │ 0.00 0.11 0.22 │ 0.00 0.16 0.86 │ 0.02 3.41 3.47 │ 0.02 8.70 14.34
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
heap │ 0.02 0.02 0.02 │ 0.00 0.03 0.03 │ 0.03 0.06 0.05 │ 0.03 0.11 0.13 │ 0.09 0.25 0.23
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
insertion │ 0.00 0.00 0.03 │ 0.00 0.00 0.11 │ 0.00 0.00 0.47 │ 0.00 0.00 1.83 │ 0.02 0.02 7.52
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
merge │ 0.00 0.00 0.00 │ 0.02 0.02 0.02 │ 0.03 0.03 0.03 │ 0.06 0.05 0.09 │ 0.11 0.11 0.19
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
pancake │ 0.00 0.00 0.08 │ 0.00 0.00 0.30 │ 0.00 0.00 1.17 │ 0.00 0.00 4.69 │ 0.00 0.02 19.22
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
quick │ 0.00 0.00 0.00 │ 0.00 0.00 0.00 │ 0.00 0.00 0.02 │ 0.00 0.02 0.05 │ 0.02 0.00 0.09
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
radix │ 0.02 0.02 0.02 │ 0.02 0.02 0.02 │ 0.03 0.03 0.03 │ 0.05 0.06 0.08 │ 0.09 0.13 0.14
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
selection │ 0.02 0.02 0.02 │ 0.08 0.08 0.09 │ 0.28 0.31 0.341.25 1.30 1.474.95 4.77 5.34
radix │ 0.00 0.00 0.00 │ 0.00 0.03 0.03 │ 0.02 0.03 0.050.05 0.08 0.080.09 0.14 0.14
shell │ 0.00 0.00 0.00 │ 0.00 0.00 0.02 │ 0.03 0.02 0.050.06 0.05 0.080.13 0.11 0.20
selection │ 0.02 0.03 0.03 │ 0.09 0.08 0.08 │ 0.33 0.33 0.381.22 1.39 1.554.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>