![]() |
|
#1
|
|||
|
|||
Doubly linked listHi,
Below is simple program of doubly linked list.I know the concept,as to how it works but i am unable to make program.Here is a program picked up from a book. CPP / C++ / C Code:
node->next->previous = node; And also in the display part,the first do while loop is ok, but how does the second do while loop knows that it has to turn back.I mean this very line- node = node->previous; has to be before the second do while loop. Can anyone tell. |
|
#2
|
||||
|
||||
Re: Doubly linked listQuote:
node1 -> node2 -> nodeX -> node3 -> node4 If current node is nodeX, point node3's previous pointer to nodeX Quote:
__________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
|
#3
|
|||
|
|||
Re: Doubly linked listThanx very much Waltp for the explaning the code.I am able to make the program but facing a little prob in insertion of the element at the end in the single linked list and double,.Below is a program that does so in a single linked list.
In the insertion function if I do so node->next=new; instead of previous->next=new; then the program does not insert the element at the end.Why an extra element is required to first traverse the list till the end and with the help of that element insertion is done? The same problem is with double linked list also.The rule says that node->next=new is to be done. CPP / C++ / C Code:
|
|
#4
|
||||
|
||||
Re: Doubly linked listQuote:
See this and this! Quote:
When you add a node at the end, the last node->next points to NULL. So when you move the pointers normally they link up fine. You should not have to process anything special except at the head node. __________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
Recent GIDBlog
2nd Week of IA Training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 07:44 |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 13:12 |
| linked list error message | Krandygrl00 | CPP / C++ Forum | 4 | 22-Jun-2005 14:13 |
| search linked list | itsmecathys | CPP / C++ Forum | 20 | 18-Apr-2005 01:34 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The