Linkedddd Listtt
Linkedddd Listtt
Concept:
Representation of linked lists
We can visualize a linked list as a chain of nodes; where every node
contains a data field and a reference link to the next node in the list.
The first node in the sequence is termed as ‘head’. And we can identify
the last node as the one which points to ‘Null’.
Each node consists of -
A data field
Reference to the next node
In c programming language
/*using structures in c creating node*/
struct node {
int data;
Node* next;
};
/* Initialize nodes */
struct node *head;
struct node *one = NULL;
struct node *two = NULL;
struct node *three = NULL;
/* Allocate memory */
one = malloc(sizeof(struct node));
two = malloc(sizeof(struct node));
three = malloc(sizeof(struct node));