TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: GEORGE WHITE
from: DAVID NOON
date: 1998-04-07 20:43:00
subject: A Question Of Sort

In a message dated 04-06-98, George White said to Tom Torfs about Qsort-ing
A Struct
Hi George,
[mega-snip]
GW>An implementation of Knuth's "Straight Selection" sort (page 140 of
GW>Knuth, Vol 3) would be:
[code snipped]
At last, another actual programmer. ... =8*)
GW>To keep David happy, some comparative timings:
Right chuffed! ... :-)
GW>Tests for short integer data normalised to 1000 repeats in clock() ticks.
GW>Set    quickersort|  bubble     |  Insertion  |  Tom's Sort |  Selection
GW>Size Rand Sort Rev Rand Sort Rev Rand Sort Rev Rand Sort Rev Rand SortRev
GW 250    5    0    1   84   46 110   34    0  68   80   47 102   47  47  47
GW>125    2    0    0   20   11  27    8    0  17   19   11  25   12  11  12
GW> 62    0    0    0    5    2   6    2    0   4    4    2   6    2    2  2
GW> 31    0    0    0    1    0   1    0    0   0    1    0   1    0    0  0
I am a little surprised that Tom's sort was marginally faster than bubble
sort, but I see why a bit further down.
I also note the omission of Shellsort. ... :-(
[snip]
GW>Compiler: BC 3.1
And now we see why that bubble sort was slower. The old Borland compiler did
not optimise the computation of j-1 in its repeated usage in the comparison
and exchange.
Everybody in this echo, even lurkers, should now face towards Scott's
Valley, California, and shout profanities at the compiler developers at
Borland.
Regards
Dave

___
 * MR/2 2.25 #353 * An Englishman never enjoys himself, except for a noble 
purpose.
--- Maximus/2 3.01
---------------
* Origin: DoNoR/2,Woking UK (44-1483-717905) (2:440/4)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.