home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!dewey.soe.berkeley.edu!werner
- From: werner@dewey.soe.berkeley.edu (John Werner)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: initing Linked Lists and then Sorting them...
- Date: 18 Dec 1992 20:10:44 GMT
- Organization: School of Education, U.C. Berkeley
- Lines: 16
- Distribution: usa
- Message-ID: <1gtb84INN829@agate.berkeley.edu>
- References: <1992Dec18.190934.7747@midway.uchicago.edu>
- NNTP-Posting-Host: dewey.soe.berkeley.edu
-
- In article <1992Dec18.190934.7747@midway.uchicago.edu> phoenix@uhuru.uchicago.edu (Lord Phoenix) writes:
- >Ok, I have been spinning in circles for the past two months and I am about
- >ready to quit... I have tried to initialize a doubly linked list and i think
- >it works, but when I try to sort it doesn't...
- >I know people must have been able to do this but I just can't figure it out...
-
- Get any good algorithms book (like Sedgwick's "Algorithms") and look
- at the section on the "merge sort". It's handy for sorting linked
- lists, and has good performance (N log N, I think). The trick when
- sorting a doubly-linked list is to treat it like a singly-linked one,
- then go back and reconstruct the back-pointers when you're done. If
- you're worried about sorting records with huge data objects in them,
- maybe you should have pointers or handles to the data instead.
- --
- John Werner werner@soe.berkeley.edu
- UC Berkeley School of Education 510-642-9651
-