Thursday 25 August 2011

Doubly Linked List

Doubly Linked List (DLL) Definition:

A doubly linked list which contains links to next and previous nodes is called as doubly linked list.
DLL allows traversal in both the directions that is we can traverse in Left to right or Right to left.

where as in Single Linked List (SLL) we can traverse only one direction that is we can traverse Left to Right only . SLL does not allow to traverse both the directions.

About Doubly Linked List:

  • Two way access is possible: we can start accessing nodes from starting node or from last node.
  • Like sll it is also Linear accessing but bidirectional i.e sequential movement is possible.
  • We can not access randomly, means no direct access is allowed.

Note:
  • It is most useful linked list
  • In dll we can access both next node data field as well as previous node field by using rlink pointer and llink pointer.
  • We have to always maintain start node, because it is the only node that is used to keep track of whole Linked list
Advantages: 

1. We can traverse in both directions i.e. from starting to end and as well as from end to starting.
2. It is easy to reverse the linked list.
3. If we are at a node, then we can go to any node. But in (Single)linear linked list, it is not possible to reach the previous node.

Disadvantages: 

1. DLL occupies much space  per each node because one extra field(data member) is required for pointer to previous node.
2. Insertion and deletion take more time than Single (Linear) linked list because more pointer operations are required than Single(linear) linked list.


Some terminology of Doubly Linked List programs

Difference between Singly Linked List and Doubly Linked List
Other Examples on Doubly Linked List
Doubly Linked List Operations
Programs on Doubly Linked List


Doubly Linked List
Circular Linked List 

No comments:

Post a Comment