sorting doubly linked list

Doug Gwyn gwyn at smoke.brl.mil
Wed May 15 05:32:42 AEST 1991


In article <OLSON.91May13142102 at sol.aaet.csc.ti.com> olson at aaet.csc.ti.com (Doug Olson) writes:
>I need an efficient method of sorting these lists based on the key
>field. Any help would be greatly appreciated.

Convert the doubly-linked list to a binary search tree (you already
have the link fields needed for that), then (if there is any need to
do so) traverse the tree in inorder, moving the nodes as they are
processed onto the tail of a doubly-linked list.



More information about the Comp.lang.c mailing list