Sorting algorithms benchmark

Stewart Gordon smjg_1998 at yahoo.com
Tue Mar 6 17:42:08 PST 2007


Deewiant Wrote:
<snip>
> I took a more detailed (but still quite cursory) look at your 
> code, and it seems you do things differently from the 
> "traditional" method.  I'm not sure if that's even equivalent 
> to the normal comb sort.

What do you consider to be the "normal comb sort"?  OK, so the call to lastSwapBubbleSort was my idea, but other than that, there doesn't seem to be any difference at all, at least from this:

http://en.wikipedia.org/wiki/Comb_sort

<snip>
>>> Other sorts that could be added:
>>>     - Gnome sort, http://en.wikipedia.org/wiki/Gnome_sort
>> 
>> Not sure if this one is worth it....
> 
> It's only a few lines of code, so there's not much to be 
> worth.  And at least it's faster than bubble sort.  ;-)

Looking at it on Wikipedia, it appears to be just a way of implementing insertion sort without nesting loops.  Strange - before, I'd understood it to be something even slower - only one index variable, and so after moving an element down you step forward one by one just to get back to where you moved it from.

Stewart.




More information about the Digitalmars-d-announce mailing list