home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!wupost!sdd.hp.com!nigel.msen.com!caen!nic.umass.edu!amherst!amhux1.amherst.edu!twpierce
- From: twpierce@amhux1.amherst.edu (Tim Pierce)
- Subject: Re: sort routines
- Message-ID: <1992Aug15.161911.28517@amhux2.amherst.edu>
- Sender: usenet@amhux2.amherst.edu (USENET News System)
- Nntp-Posting-Host: amhux1.amherst.edu
- Organization: Amherst College, Amherst MA
- References: <1992Aug13.170424@axion.bt.co.uk> <1992Aug13.181541.26041@news.uit.no>
- Date: Sat, 15 Aug 1992 16:19:11 GMT
- Lines: 23
-
- In article <1992Aug13.181541.26041@news.uit.no> tomg@stud.cs.uit.no (Tom Grydeland) writes:
-
- >As far as I know, the best solution for sorting a single linked list is the
- >mergesort. It's a recursion-based sorting which follows the general solution:
- >
- >0) If the list is just one element, it's sorted, return.
- >
- >1) If not, split your list in two approximately equal sublists.
- >
- >2) Mergesort (here's the recursion!) each one separately.
- >
- >3) Merge the two sorted sublists, and you have a sorted list to return.
-
- An addendum: insertion and selection sort tend to work pretty well on
- very short lists (the cutoff is around seven-element lists, in my
- experience). I've been able to improve recursive sorts from time to
- time by ending the recursion early and using one of these sorts for
- the last little bits.
-
- --
- ____ Tim Pierce / "Bisexual just means you pay for it."
- \ / twpierce@amherst.edu /
- \/ (BITnet: TWPIERCE@AMHERST) / -- Rock Hudson
-