|
Double Linked vs. Single Linked lists
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Nick Cash
USA (610 posts) bio
|
| Date |
Fri 29 Jul 2005 10:59 PM (UTC) [ quote
] |
| Message |
I was wondering for a while now. I always use doubly linked lists when I need a linked lists. This is probably habbit from programming on my mud for so long, but I'm not really sure what the bennefit is.
A friend of mine dislikes keeping track of the last object within a list. So he tends to use singely linked lists.
Can anyone tell me the advantage of a doublely linked list compared to a singely linked list? I've never really had a reason to parse the list backwards. |
~Nick Cash
http://www.nick-cash.com | top |
|
| Posted by |
Nick Gammon
Australia (15,683 posts) bio
|
| Date |
Mon 01 Aug 2005 07:33 AM (UTC) [ quote
] |
| Message |
| Simply to be bidirectional. You have slightly more storage needed (a forwards and backwards link) plus slightly more work to do when adding/deleting items. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
| Posted by |
David Haley
USA (3,802 posts) bio
|
| Date |
Mon 01 Aug 2005 07:09 PM (UTC) [ quote
] |
| Message |
Doubly-linked lists also make it easier to remove things from the list. If you're stepping through a singly-linked list and want to remove something, you have to keep track of the previous element. Not hard, but it's something you have to do.
You also don't have to keep track of the last object in a doubly-linked list, unless your list is circular.
In any case, a doubly-linked list has four extra bytes of overhead per element when compared to a singly-linked list. This is significant for lists of characters (i.e. char) but negligible for lists of game-characters (i.e. char_data). |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | top |
|
| Posted by |
Rajeswari
(1 post) bio
|
| Date |
Wed 24 Aug 2005 06:06 AM (UTC) [ quote
] |
| Message |
In my view DLL are very flexible in adding & removing elements.
in Data storage we create the index for easy retrive & insert & delete records.
Nowadays Datawarehousing is one of the interesting topic. in DBMS fast retreving of data is important. for this, Binary search is more advantageous. pointer points to any record, move easily to any direction, so that we get record in less amount of time.
There is lot of secondary memory or disk space available. so do't bother about wastage of memory. thanq. | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
3,122 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )