Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ Programming ➜ General ➜ Double Linked vs. Single Linked lists

Double Linked vs. Single Linked lists

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Nick Cash   USA  (626 posts)  Bio
Date Fri 29 Jul 2005 10:59 PM (UTC)
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  (23,057 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 01 Aug 2005 07:33 AM (UTC)
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,881 posts)  Bio
Date Reply #2 on Mon 01 Aug 2005 07:09 PM (UTC)
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 Reply #3 on Wed 24 Aug 2005 06:06 AM (UTC)
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.


22,708 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.