[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  Programming
. -> [Folder]  General
. . -> [Subject]  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] Refresh page


Posted by Nick Cash   USA  (626 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (22,990 posts)  [Biography] 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
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] 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
[Go to top] top

Posted by Rajeswari   (1 post)  [Biography] 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.
[Go to top] 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.


21,765 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]