Doubly Circular linked list
Doubly Circular linked list has both the properties of doubly linked list and circular linked list. Two consecutive elements are linked by previous and next pointer and the last node points to first node by next pointer and also the previous pointer of the head node points to the tail node. This two way pointer linking has eliminated all the short comings of all previous linked lists which have been discussed in the previous sections. Node traversal from any direction is possible and also jumping from head to tail or from tail to head is only one operation: head pointer previous is tail and also tail pointer next is head. Find the visual representation of the doubly circular linked list in the below figure.
Doubly Circular linked list - pictorial view
Doubly Circular linked list - Data Structure
Advantages
- List can be traversed bothways from head to tail as well as tail to head
- Being a circular linked list tail can be reached with one operation from head node
Disadvantages
- It takes slightly extra memory in each node to accomodate previous pointer
Practical Applications
- Managing songs playlist in media player applications
- Managing shopping cart in online shopping
Doubly Circular linked list source code
This is a minimal demo application to show the functionalities of doubly circular linked list. We are taking user's input to pupulate the nodes in the list. List is getting populated with the logic add at tail like a queue. We quit the node addition iteration as user press (n) and jumps to the display nodes section. This linked list can be iterated from head to tail as well as from tail to head. We are displaying list with these two iteration logic and finally freeing the list by deleting each node one by one. Deletion process can be from head to tail or vice versa and we are showing head to tail login here.
Program Output
Doubly circular linked list demo application Add a node [y/n] : y Value of this node : 1 Add a node [y/n] : y Value of this node : 10 Add a node [y/n] : y Value of this node : 100 Add a node [y/n] : n List Contains(sequence head to tail): Node 1, Value: 1 Node 2, Value: 10 Node 3, Value: 100 List Contains(sequence tail to head): Node 1, Value: 100 Node 2, Value: 10 Node 3, Value: 1
About our authors: Team EQA
You have viewed 1 page out of 252. Your C learning is 0.00% complete. Login to check your learning progress.