473,326 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

sorting a linked list

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
4 8944
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

"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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kakarot | last post by:
I'm gona be very honest here, I suck at programming, *especially* at C++. It's funny because I actually like the idea of programming ... normally what I like I'm atleast decent at. But C++ is a...
18
by: Matthias Kaeppler | last post by:
Hi, in my program, I have to sort containers of objects which can be 2000 items big in some cases. Since STL containers are based around copying and since I need to sort these containers quite...
3
by: darth | last post by:
Does anyone have heap sorting with queue(doublely linked list) in C? I have heap sort with array but with queue, it's somewhat hard.
3
by: sugaray | last post by:
hi, i have to build a linked-list which has another sturcture _score as it's data entry, so how can i sort such linked-list based on, let say, history score into proper order...
7
by: Foodbank | last post by:
Hi everyone. I'm having trouble with this radix sorting program. I've gotten some of it coded except for the actual sorting :( The book I'm teaching myself with (Data Structures Using C and...
4
by: Peter Schmitz | last post by:
Hi, in my application, I defined a linked list just as follows: typedef struct _MYLIST{ int myval; void *next; }MYLIST; MYLIST head;
1
by: PhilB | last post by:
I have been having issues trying to merge sort a double linked list. (I would supply the code, but it is locked away on an inaccessable computer.) The list always results in an unsorted list, but...
4
by: FBM | last post by:
Hi, I am working on a program that simulates one of the elements of ATM. The simulation stores events which occurs every some milliseconds for a certain amount of time. Every time that an event...
20
by: martin-g | last post by:
Hi. Mostly I program in C++, and I'm not fluent in C# and .NET. In my last project I began to use LinkedList<and suddenly noticed that can't find a way to sort it. Does it mean I must implement...
4
by: arnuld | last post by:
This program follows from the section 6.5 of K&R2 where authors created a doubly-linked list using a binary-tree based approach. The only thing I have rewritten myself is the getword function. I am...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.