A circular linked list is a type of linked list in which the last node of the list points back to the first node. In single or double linked list the last node contains a NULL pointer since there is no next node, whereas in a circular linked list the "next" pointer of the last node contains the address of the first node. Therefore it is called a circular linked list. A circular linked has a "start" node, but no "end" node. In a Circular Linked List all the nodes are linked in continuous circle. Whatever operations are possible using singly linked lists, all those operations can be performed using circular lists also. A circular list can be used as a stack, queue or a deque.
It can be both Singly or doubly linked list. In a circular linked list elements can be added to the back of the list and removed from the front in constant time.Both types of circularly-linked lists benefit from the ability to traverse the full list beginning at any given node. This avoids the necessity of storing first Node and last node, but we need a special representation for the empty list, such as a last node variable which points to some node in the list or is null if it's empty. This representation significantly simplifies adding and removing nodes with a non-empty list, but empty lists are then a special case.Circular linked lists are most useful for describing naturally circular structures,and have the advantage of being able to traverse the list starting at any point. They also allow quick access to the first and last records through a single pointer (the address of the last element).
0 comments:
Post a Comment