Circular Doubly Linked List | Advantages | Disadvantages | Example | BitsOfCS


Circular doubly linked list is a mixture or combination of doubly linked list and circular linked list. In a circular doubly linked list two successive nodes are linked by previous pointer and next pointer. The first node points to the last node by the previous pointer and the last node points to the first node by the next pointer.

Example– The below example shows us how to create circular doubly linked list and how to traverse it.


Output

This is how our circular doubly linked list looked like.


If you want to understand the above program then click here!

Advantages of Circular Doubly Linked List:

  1.  We can traverse the list from both sides i.e. from first node to the last node or last node to the first node. We can jump from first node to last node or last node to first node in O(1) i.e. in constant time complexity.

  2. We can implement some complex data structure like a fibonacci heap using a circular doubly linked list.

Disadvantages of Circular Doubly Linked List:

  1.  You can see in the above example, we have to maintain a lot of pointers to implement a circular doubly linked list. So, we have to handle pointers carefully otherwise the data of the linked list may be lost.

  2.  Because of a lot of pointers it takes extra memory.

Applications of Circular Doubly Linked List:

  1.  In a media player, a circular doubly linked list is used in order to maintain songs in the playlist.

  2.  Also this data structure is used in e-commerce websites to maintain shopping carts.

Also read: Doubly Linked List

Also read: Circular Linked List

If you find any problem related to this article, please comment below or contact me here.


manorinfinity Written by:

Complex Problem Solver, Outloud Thinker, An Outstanding Writer, and a very curious human being

Be First to Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.