Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Data Address of Next Node Data Address of Next Node Data Address of Next Node
HEAD
Prev Data Next Prev Data Next Prev Data Next NULL
NULL
In doubly linked list, the next pointer of the last node points to the first node
and the previous pointer of the first node points to the last node making the
circular in both directions.
As per the above illustration, following are the important points to be considered.
The last node’s next field points to the first node of the list in both cases of
singly as well as doubly linked list.
The first node’s previous points to the last node of the list in case of doubly
linked list.
C representation of circular linked list
We declare structure for the circular linked list in the same way as linear
linked list.
Struct node
{
int info;
Struct node*next;
};
Typedef struct node NodeType;
NodeType*star=NULL;
NodeType*last=NULL;
Basic Linked List Operations
We can treat linked list as an abstract data type and perform following basic operations:
Creating Linked List.
Traversing Linked List.
Printing Linked List.
Counting Number of Nodes in Linked List.
Searching element in Linked List.
Concatenating two Linked List.
Inserting element into Linked List (Start, end and Specific Position)
Deleting elements from Linked List (Start, End and specific position)
And Many more operations.
Example: working with linked list
Consider the structure of a node as follows:
Struct stud {
int roll;
char name[25];
int age;
struct stud *next;
};