Recent Posts

Friday, 29 December 2017

Circular Linked Lists

Circular Linked Lists
     In singly linked lists and doubly linked lists, the end of lists are indicated with NULL value. But circular linked lists do not have ends. That means circular linked list is similar to the single linked list except that the last node points to the first node in the list. While traversing the circular linked lists we should be careful; otherwise we will be traversing the list infinitely.
E.g
Advantages
1. Circular Doubly Linked Lists are used for implementation of advanced data structures like Fibonacci Heap
2. Entire list can be traversed from any node.
3. Despite of being singly circular linked list we can easily traverse to its previous node, which is not possible in singly linked list.

Disadvantages
1. Circular list are complex as compared to singly linked lists.
2. Reversing of circular list is a complex as compared to singly or doubly lists.
3. If not traversed carefully, then we could end up in an infinite loop.
4. Like singly and doubly lists circular linked lists also doesn’t supports direct accessing of elements.

Applications/Uses of Circular linked list in real life
1. Circular lists are used in applications where the entire list is accessed one-by-one in a loop. Example: Operating systems may use it to switch between various running applications in a circular loop.
2. It is also used by Operating system to share time for different users, generally uses Round-Robin time sharing mechanism.
3. Multiplayer games uses circular list to swap between players in a loop.

 
 

No comments:

Post a Comment