Friday, July 16, 2010

I wanna know details about doubly linked list?

I know singly linked list

I wanna know details about doubly linked list?
The only difference is that the Double Linked List contains both a pointer to the next node, similar to a Single Linked List, and it also contains a pointer to the previous node. This allows the client to traverse the list both forward and backwards with little effort.





Say you needed to get to the previous node with a single linked list, you would have to start back at the beginning of the list and walk down to it. Or create another node object in your client application that remembers the previous node. With a Double Linked List it is as simple as hitting rewind. ;-)
Reply:A doubly linked list is a list wherein the nodes point to the next and previous nodes in the list (thus double or two links versus one for a singly linked list). You would use a doubly linked list if you wanted to traverse the list in both directions. With a singly linked list, you can only traverse from first node to last.





It does add a little complexity to inserting and deleting nodes in the list. You will have another pointer to modify in either case.
Reply:Here is a link to an article that explains Doubly Linked Lists, as well as other types:
Reply:If you know single linked lists you basically know double


linked ones as well. The difference is just that the double


linked version has a backward pointer as well.


No comments:

Post a Comment