Circular Linked List Algorithm
Circular Linked List Algorithm
http://www.tutorialspoint.com/data_structures_algorithms/circular_linked_list_algorithm.htm
Copyright © tutorialspoint.com
Circular Linked List is a variation of Linked list in which first element points to last element and last
element points to first element. Both Singly Linked List and Doubly Linked List can be made into as
circular linked list.
As per above shown illustrations, following are the important points to be considered.
Last Link's next points to first link of the list in both cases of singly as well as doubly linked list.
First Link's prev points to the last of the list in case of doubly linked list.
Basic Operations
Following are the important operations supported by a circular list.
Insertion Operation
Following code demonstrate insertion operation at in a circular linked list based on single linked
list.
if (isEmpty()) {
head = link;
head->next = head;
}else {
//point it to old first node
link->next = head;
Deletion Operation
Following code demonstrate deletion operation at in a circular linked list based on single linked
list.
if(head->next == head){
head = NULL;
return tempLink;
}
printf(" ]");
}