Article View: rec.games.programmer
Article #1052Re: Advice needed for fastest sort algorthm
From: Gard Eggesbo Abrahamsen
Date: Tue, 10 Nov 1992 12:21
Date: Tue, 10 Nov 1992 12:21
27 lines
2028 bytes
2028 bytes
Kristof Roomp (krisr@cue.bc.ca) wrote: : In article <1992Nov8.012628.23338@menudo.uh.edu> libh@Jane.UH.EDU writes: : > The bubble sort takes N! (# factorial) steps, rather than N*N steps. A BIG : >difference. But as pointed out, the quicksort is the easiest to implement : >since it is in C libraries. Why reinvent the wheel. If that isn't quick : >enough then I would check out Knuth's 'Art of Programming' Vol. 3 since it is : >pretty much only about sorting. : > : nope.its worst case is n*n where n is the number of items in the list... : you have to watch the quicksort with lists of objects which are already : sorted, because its performance on a sorted list is a lot worse than : the bubble sort. on a presorted list , the quicksort will also use : in the order of n stack space. This could be prevented by taking a different : pivot element when quicksorting (like the middle one). the library quicksort : uses the first element. : Some time back, I and a friend of mine were competing on who could write the fastest sort routine. The fastest result was combining the bubble and the quick sort routines, like using the bubble to determine the threshold as well as checking wether the data already was sorted or not. This way, the routine would have only one pass if the list already was sorted. I COULD see if I can find the routine, if I look in my archived routines library. I have one written for Power BASIC (on the Atari ST series computers) and another one written in pure 68000 assembler. /Gard
Technical Details
Message-ID:
<1992Nov10.122106.27684@ugle.unit.no>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!ugle.unit.no!unix1!gardabrReferences:
<1992Nov10.011231.19813@softwords.bc.ca>Show Full Headers
Complete Article Headers
Newsgroups: rec.games.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!ugle.unit.no!unix1!gardabr From: gardabr@unix1 (Gard Eggesbo Abrahamsen) Subject: Re: Advice needed for fastest sort algorthm Message-ID: <1992Nov10.122106.27684@ugle.unit.no> Sender: news@ugle.unit.no (NetNews Administrator) Organization: University of Trondheim, Norway X-Newsreader: TIN [version 1.1 PL6] References: <1992Nov10.011231.19813@softwords.bc.ca> Date: Tue, 10 Nov 92 12:21:06 GMT Lines: 27