By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,513 Members | 1,810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,513 IT Pros & Developers. It's quick & easy.

sorting a linked list

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Please read data structure!! you can find many algorithm there!
"ram" <ra******@rediffmail.com>
??????:53**************************@posting.google .com...
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

Nov 13 '05 #2

P: n/a

"hercules" <we*****@harbournetworks.com> 写入消息新闻
:bd***********@mail.cn99.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
Nov 13 '05 #3

P: n/a
"Jason Xie" <ja******@gdnt.com.cn> wrote:
"hercules" <we*****@harbournetworks.com> 写入消息新闻
:bd***********@mail.cn99.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
Nov 13 '05 #4

P: n/a
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 --

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.