Newsgroups: comp.sys.mac.programmer.help,comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!newstand.syr.edu!news.maxwell.syr.edu!www.nntp.primenet.com!nntp.primenet.com!enews.sgi.com!news.sgi.com!news.tamu.edu!news.utdallas.edu!nrchh45.rich.nt.com!bcarh189.bnr.ca!nott!kwon!watserv3.uwaterloo.ca!undergrad.math.uwaterloo.ca!knspilka
From: knspilka@undergrad.math.uwaterloo.ca (Keir Spilka)
Subject: Re: Mergesort: why's it efficient?
Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
Message-ID: <E2DotH.5I@undergrad.math.uwaterloo.ca>
Date: Sat, 14 Dec 1996 00:46:29 GMT
References: <ejrE1twH2.70u@netcom.com> <32A587C0.60D9@vader.brad.ac.uk> <32aa05d0.27633490@news.tu-graz.ac.at>
Nntp-Posting-Host: descartes.uwaterloo.ca
Organization: University of Waterloo
Lines: 28
Xref: glinda.oz.cs.cmu.edu comp.sys.mac.programmer.help:45047 comp.lang.lisp:24238

Sorry, I just got in on this discussion, but here's the straight goods.

On average, Quicksort is actually faster than Mergesort, but Mergesort has
a couple of nice features:

Mergesort GUARANTEES O(nlogn) runtime.  By the same token, it always
performs all of the steps.  Ie.  There are no skipped steps or
advantageous cases in most codings of the algorithm.  Unless you drop out
of the mergesort at a sufficiently small size of arrays to use an
insertion sort or something else which works well on small problems.  

Furthermore Mergesort is a stable algorithm.  Ie.  It sorts identical
elements and leaves them in their original positions.  This is
advantageous in certain conditions.  Ie.  Imagine a contest for guessing
the number of jelly beans in a jar.  If a bunch of people have the correct
answer, you want the prize to go to the first person who submitted his
entry.....You get the picture.  


THe main problem is extra space requirements, but its guaranteed runtime
is a big plus!

Keir
-- 
------------------------------------------------------------------------------
Keir Spilka		      knspilka@undergrad.math.uwaterloo.ca
2B CS/EEE Major		      http://www.undergrad.math.uwaterloo.ca/~knspilka
University of Waterloo
