sorting a linked list

Discussion in 'C Programming' started by ram, Jul 3, 2003.

  1. ram

    ram Guest

    I have created a long link list...and now need to sort it according to
    the index value(of type double) of each node.Can someone point me
    toward an efficient algorithm to sort it after creation.
    I cannot order it during creation as I am able to calculate the index
    value only after I have created the whole list.

    Thanks
    ram, Jul 3, 2003
    #1
    1. Advertising

  2. ram

    hercules Guest

    Please read data structure!! you can find many algorithm there!
    "ram" <>
    ??????:...
    > I have created a long link list...and now need to sort it according to
    > the index value(of type double) of each node.Can someone point me
    > toward an efficient algorithm to sort it after creation.
    > I cannot order it during creation as I am able to calculate the index
    > value only after I have created the whole list.
    >
    > Thanks
    hercules, Jul 3, 2003
    #2
    1. Advertising

  3. ram

    Jason Xie Guest

    "hercules" <> дÈëÏûÏ¢ÐÂÎÅ
    :bdvuu9$2tq3$99.com...
    > Please read data structure!! you can find many algorithm there!


    Quick sort is the best one.

    But in fact many algorithms in book doesn't work well, you must perfect it
    before you put it into you code.

    --
    jason
    Jason Xie, Jul 3, 2003
    #3
  4. ram

    Richard Bos Guest

    "Jason Xie" <> wrote:

    > "hercules" <> дÈëÏûÏ¢ÐÂÎÅ
    > :bdvuu9$2tq3$99.com...
    > > Please read data structure!! you can find many algorithm there!

    >
    > Quick sort is the best one.


    For a linked list? Probably not. Try merge sort.

    Richard
    Richard Bos, Jul 3, 2003
    #4
  5. ram wrote:
    > I have created a long link list...and now need to sort it according to
    > the index value(of type double) of each node.Can someone point me
    > toward an efficient algorithm to sort it after creation.


    Mergesort is the best alg. I can think of right now for list sorting.

    also if you need a book on the topic, I would suggest Sedgewick's
    "Algorithms in C", I have the C++ version and it is the best book I've
    seen for the algorithms and data structures...

    -- Nuclear / the Lab --
    John Tsiombikas (Nuclear / the Lab), Jul 3, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Ritchey
    Replies:
    7
    Views:
    476
    emerth
    Jul 10, 2003
  2. Chris Ritchey

    Generating a char* from a linked list of linked lists

    Chris Ritchey, Jul 9, 2003, in forum: C Programming
    Replies:
    7
    Views:
    463
    emerth
    Jul 10, 2003
  3. fool
    Replies:
    14
    Views:
    501
    Barry Schwarz
    Jul 3, 2006
  4. joshd
    Replies:
    12
    Views:
    664
    John Carson
    Oct 2, 2006
  5. jawdoc
    Replies:
    9
    Views:
    747
    Chris Thomasson
    Mar 10, 2008
Loading...

Share This Page