![]() |
|
#1
|
|||
|
|||
Need help with linked listsHello!
I'm a having some trouble doing a list of linked lists of countries exercise,each of which have survey replies.The exercise says: "Write a function in c that detects when a country does not follow alphabetical order.The function must find that country(assume there's only one district!) and place it on the correct location on the list.All the information regarding the survey must be preserved.The function takes as an argument a pointer to the beggining of the list of countries(main list) and returns that same pointer updated" What I have trouble is, how will I run through the linked list?Do I have to use some kind of algorithm like bubble sort?Or is there any simpler way?And if I use bubble sort,how do I make a stopping condition once the district that wasn't in place gets ialphabetically ordered? Here's what I have right now,but what it does is,that only considers the element tha follows the 1st element to be alphabetically lower than it(Ex: Belgium->Australia->New Zeland -> Australia->Belgium->New Zeland) Here's the code: CPP / C++ / C Code:
|
|
#2
|
|||
|
|||
Re: Need help with linked listsQuote:
You just need iterate from head of list until tail of list. You should use insertion sort. __________________
Linux is the best OS in the world. |
Recent GIDBlog
Meeting the local Iraqis by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Linked Lists Database... | TS3BxL | C++ Forum | 10 | 19-Mar-2008 22:37 |
| Linked Lists problem | kracivi | C Programming Language | 1 | 01-May-2007 08:40 |
| Doubly linked lists in C++ | sweeeeeeetlipss | C++ Forum | 1 | 23-Oct-2006 23:27 |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 13:12 |
| Linked lists | vortz83 | C++ Forum | 3 | 20-Mar-2004 06:56 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The