In this recipe, we will learn how to implement a circular linked list. The difference between a linear linked list and a circular linked list is that where the last node of the linear linked list points at NULL, the pointer of the last node in a circular linked list points back to the first node, hence allowing the pointer to traverse in a backward direction too.
Implementing a circular linked list
How to do it...
Follow these steps to implement a circular linked list:
- Define a structure called node. To store data in a circular linked list, define a data member in the node structure. Besides a data member, define a pointer that will point at the next node.
- A pointer called startList is initialized to NULL. The startList pointer...