what is Circular Linked List?


The linked lisis that we have seen so far are often known as linear linked lists. The elements of such a linked list can be accessed, first by setting up a pointer pointing to the first node in the list and then traversing the entire list using this pointer. Although a linear linked list is a useful data structure, it has several shortcomings. For example, given a pointer p to a node in a linear list, we cannot reach any of the nodes that precede the node to which p is pointing. This disadvantage can be overcome by making a small change to the structure of a linear list such that the link field in the last node contains a pointer back to the first node rather than a NULL. Such a list is called a circular linked list.

No comments:

Post a Comment