Sorting linked lists
Wayne Throop
throopw at dg_rtp.UUCP
Fri Apr 4 07:22:43 AEST 1986
I've posted a "C" version of Craig Hansen's NlogN singly-linked list
sort to net.sources. It is titled "singly-linked list sort in C". It
is organized as a general-purpose routine, usable to sort lists of any
node type. It assumes that your C compiler does reasonable things with
structure layout, but this can be made compiler specific fairly easily
if your compiler is peculiar.
The main differences of this routine relative to Craig Hansen's offering
are these:
- I've heavily commented it to make clear what is going on.
(I did this because I didn't follow in detail what Craig's did until
I had translated it to C and tinkered with it a little. Craig's
was *clear* enough, I was just a little slow...)
- I've generalized it as mentioned above.
- I've traded time spent moving a bookeeping pointer through the list
against keeping a little more bookeeping information around. (The
bookeeping space is still constant in N, however.)
- I've included a small testing routine, so you can see if it works
for you.
Have fun, sorting freeks, and my apologies if zillions of list sorting
routines have already been posted to net.sources.
--
Wayne Throop at Data General, RTP, NC
<the-known-world>!mcnc!rti-sel!dg_rtp!throopw
More information about the Comp.lang.c
mailing list