Article View: rec.games.programmer
Article #1024Re: Advice needed for fastest sort algorthm
From: libh
Date: Sun, 08 Nov 1992 01:26
Date: Sun, 08 Nov 1992 01:26
31 lines
2333 bytes
2333 bytes
In article <BxD5pt.DyI@news.cso.uiuc.edu>, jas37876@uxa.cso.uiuc.edu (John A. Slagel) writes: >kds@phy.duke.edu (Stokes Kevin) writes: > > >> This new project has objects much closer to the observer, and I fear >>there may be significant changes in the list order between every sort. >>Which sorting algorthm is the most time efficient? > > Definately the quick sort. Its even built into ANSI C specs, so it > should be easy to implement. Look up quicksort in your C manual. If > I remember right, bubble sort works in O(n*n) and quicksort works in > O(n*log n). > > In other words, if you're sorting n objects, QuickSort takes "on the Order > of" n*log n steps, while bubble sort takes "on the order of" n*n steps. > 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. ******************************************************************************** * | What do I see? * * | I see time as it affects all things . . . * * John White | Human flesh withers and dies before my eyes. . * * | Flowers bloom only to fade . . . * * Libh@Jetson.uh.edu | Trees drop green leaves, never to regain them * * | In my sight. . .it is always winter. . .always night * * | -- Raistlin -- * ********************************************************************************
Technical Details
Message-ID:
<1992Nov8.012628.23338@menudo.uh.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!menudo.uh.edu!Jane.UH.EDU!LIBHReferences:
<6759@news.duke.edu>,<BxD5pt.DyI@news.cso.uiuc.edu>Show Full Headers
Complete Article Headers
Newsgroups: rec.games.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!menudo.uh.edu!Jane.UH.EDU!LIBH From: libh@Jane.UH.EDU Subject: Re: Advice needed for fastest sort algorthm Message-ID: <1992Nov8.012628.23338@menudo.uh.edu> Sender: usenet@menudo.uh.edu (USENET News System) Nntp-Posting-Host: jane.uh.edu Reply-To: libh@Jane.UH.EDU Organization: University of Houston References: <6759@news.duke.edu>,<BxD5pt.DyI@news.cso.uiuc.edu> Date: Sun, 8 Nov 1992 01:26:28 GMT Lines: 32