Article View: rec.games.programmer
Article #1027Re: Advice needed for fastest sort algorthm
From: Michael O'Reilly
Date: Sun, 08 Nov 1992 14:01
Date: Sun, 08 Nov 1992 14:01
26 lines
1655 bytes
1655 bytes
John A. Slagel (jas37876@uxa.cso.uiuc.edu) wrote: : 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). Wait a bit.. Quicksort is nothing like the best. It has an AVERAGE running time of N log N, but the worst case is n^2. The worst case occurs when the data is already sorted.... Nearly sorted data does very badly. On top of this, the quicksort is difficult to implement efficently. If you want a real FAST sort, implement a merge sort, or a radix sort (radix is O(n), but it is only useful for small numbers). Merge has a worst case of N log N, but needs more memory than a quicksort. On the up side, it can be made very fast. : John A. Slagel, email: jas37876@uxa.cso.uiuc.edu Michael
Technical Details
Message-ID:
<1dj6jmINNder@tartarus.uwa.edu.au>Path:
arc1-ca.pugleaf.net!sparky!uunet!pmafire!news.dell.com!natinst.com!cs.utexas.edu!usc!rpi!batcomputer!munnari.oz.au!uniwa!uniwa!nfmReferences:
<BxD5pt.DyI@news.cso.uiuc.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!pmafire!news.dell.com!natinst.com!cs.utexas.edu!usc!rpi!batcomputer!munnari.oz.au!uniwa!uniwa!nfm From: oreillym@tartarus.uwa.edu.au (Michael O'Reilly) Newsgroups: rec.games.programmer Subject: Re: Advice needed for fastest sort algorthm Date: 8 Nov 1992 22:01:26 +0800 Organization: Home Lines: 26 Message-ID: <1dj6jmINNder@tartarus.uwa.edu.au> References: <BxD5pt.DyI@news.cso.uiuc.edu> NNTP-Posting-Host: tartarus.uwa.edu.au X-Newsreader: TIN [version 1.1 PL6]