From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cda33fc7f63c2885 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-08 09:21:39 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!opentransit.net!proxad.net!feeder2-1.proxad.net!news1-2.free.fr!not-for-mail Newsgroups: comp.lang.ada Subject: Re: list strawman References: <7iE_7.8661$cD4.15714@www.newsranger.com> <3c3b13ba$0$212$626a54ce@news.free.fr> From: Jean-Marc Bourguet Date: 08 Jan 2002 18:21:35 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Message-ID: <3c3b2aa0$0$212$626a54ce@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 08 Jan 2002 18:21:37 MET NNTP-Posting-Host: 158.140.208.29 X-Trace: 1010510497 news1-2.free.fr 212 158.140.208.29 X-Complaints-To: abuse@proxad.net Xref: archiver1.google.com comp.lang.ada:18654 Date: 2002-01-08T18:21:37+01:00 List-Id: Ted Dennison writes: > In article <3c3b13ba$0$212$626a54ce@news.free.fr>, Jean-Marc Bourguet says... > > > >How do you do quicksort on a list? quicksort assume random access so > >you'll have O(n) space overhead. I'd use a merge sort on a list which > >would have the same complexity as quicksort and do not need random > >access. > > I don't see that. I'm sorry, I was thinking about heap sort. > The way it works, all you have to keep track of is the ends of the > list (or sublist you are working on), the pivot point, and a couple > of pointers that iterate through the list. There's nothing in there > that can't be done easily with a doubly-linked list. Yes. There is still the problem of choosing the pivot. With random access, I'd use a random element. Without random access, you'll have to choose the first or the last element and then degenerate in N^2 for a sorted input, not something I'd like in a general purpose library. Well taking a random element is possible but at a cost of iterating some more time on the whole list. Perhaps there is a way to even choose the next pivot while you construct the upper and lower list but I don't see one. Well, I think I'd still choose a merge sort. Yours, -- Jean-Marc