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,a4d4bd32123b67d4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-03 06:59:31 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!news.gtei.net!nntp.abs.net!feeder.qis.net!btnet-peer!btnet-peer0!btnet!news5-gui.server.ntli.net!ntli.net!news6-win.server.ntlworld.com.POSTED!not-for-mail From: "chris.danx" Newsgroups: comp.lang.ada References: <1408ce1d.0201011425.29c12c97@posting.google.com> <1408ce1d.0201021422.3ef052f6@posting.google.com> Subject: Re: A little help with Quicksort X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Message-ID: Date: Thu, 3 Jan 2002 14:54:50 -0000 NNTP-Posting-Host: 213.104.127.136 X-Complaints-To: abuse@ntlworld.com X-Trace: news6-win.server.ntlworld.com 1010069655 213.104.127.136 (Thu, 03 Jan 2002 14:54:15 GMT) NNTP-Posting-Date: Thu, 03 Jan 2002 14:54:15 GMT Organization: ntlworld News Service Xref: archiver1.google.com comp.lang.ada:18477 Date: 2002-01-03T14:54:50+00:00 List-Id: "Mond" wrote in message news:1408ce1d.0201021422.3ef052f6@posting.google.com... > Hi, > > thanks for the help! > > > Do you undestrand the algorithm and it's solution (for arrays)? Converting > > the array solution to lists like that will not work, or at least not as > > easily as it would if you take the main points (choose pivot, partition, > > sort) of the algorithm and coded them. My suggestion is to break the list > > into two lists, and don't try to move the pointers about. > > I think i understand the algorithm, so i started from scratch again > with good old paper and pencil drawing out the nodes and pointers. I > got it to work out on paper by partitioning the list into two (like > you said), the left list containing all values less than the pivot > (where pivot = the first value in the list) and the right list > containing all values greater or equal to the pivot. Then the pivot > node is prepended to the left list and its value swapped with the last > value in that list. Eventually the lists gets smaller and smaller > until it is just one node. Here the nodes should be re-built by > joining them together until the original list is in its sorted form. > (Phew!) ;) That's almost right. You add the pivot to the end of one of the unsorted lists (the lesser than list). What happens on pen and paper? Does it work ok? > Here, (joining the nodes together again), is where i had trouble > trying to transfer this from paper into code. I can't work out where > to put the code - i think its somewhere like the place that is denoted > by the stars in the code below. Also, i think the code to to this > involves Prepend. Where does it make sense to join the lists you got together? Before you've sorted? After you've sorted? > If anyone could please have a look - if you can be bothered! ;) - it > would be greatly apreciated!!! > > Thanks again! > > Mond > > PS Chris, are you perhaps in Level 2 Computing Sci @ Glasgow Uni? :) Yes. Chris