in reply to Re: Doubly link list implementation
in thread Doubly link list implementation
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Doubly link list implementation
by punitpawar (Sexton) on Nov 25, 2015 at 19:04 UTC | |
Although I am able to do the insert correctly , when I try to print the output starting from the head . I do not see node that I had inserted before the tail node. Similarly when I print the output starting from the tail node , I do not see node that I inserted after the head node. Observe the values printed in the "current" field from my output. Any corrections/ suggestions which you can provide will be very helpfulhere is my code Output form this program content of datastored.txt
| [reply] [d/l] [select] |
by Laurent_R (Canon) on Nov 26, 2015 at 10:56 UTC | |
It seems that you've found a solution by now, but if you really want to build a doubly-linked list, you should most probably create separate subs to insert new nodes (and also subs to delete nodes). Subs to insert nodes could go like this: While we are at it, I think we should also move the displaying of the content into a separate sub: I now change the program of my previous post to add two nodes after the original construction of the data structure, and display the structure before and after these insertions: This prints out the following: But, there is more to it.
Read more... (2 kB)
I hope this helps.
| [reply] [d/l] [select] |
by punitpawar (Sexton) on Nov 25, 2015 at 23:13 UTC | |
I never created the link backward from the newly added node. Again thanks everyone for your responses and help See my revised code below . Output Content of datastored.txt
| [reply] [d/l] [select] |