- Linked list is a linear type of data structure.
- It is a set of data which has data along with the address stored in it.
- Linked list store the data and address in a node.
**Node:-**Node is a combination of data and the next (address of next node).

Linked list is a collection of node having following format.

Above node contain two field of different type in a node. Therefore to implement a node we use a type of structure to form node.

12345 | Struct node{int data;Struct node * next;} |

In which data stores int type data in a node and the next pointer points next node of a same type structure.

Now we will see how exactly the linked list be implemented in C.

## Program

In this we simply create a linked list with 3 nodes P1, P2, P3 As given below.

12345678910111213141516171819202122232425262728293031323334 | #include<stdio.h>Struct node{int data;Struct node *next;}void main(){Struct node *p1,*p2,*p3;Struct node *start,*temp;p1=(Struct node*)malloc(sizeof(struct node));p2=(Struct node*)malloc(sizeof(struct node));p3=(Struct node*)malloc(sizeof(struct node));p1->next=p2;p2->next=p3;p3->next=NULL;start=p1;temp=start;temp->data=10;temp=temp->next;temp->data=20;temp=temp->next;temp->data=30;temp=temp->next;temp=start;//Display Linked Listprintf(“%d”,temp->data);temp=temp->next;printf(“%d”,temp->data);temp=temp->next;printf(“%d”,temp->data);temp=temp->next;} |

In above linked list, We simply create nodes in c and for creating and allocating address to node we used **malloc()** which allocates memory dynamically and after that we linked the nodes.

**Example:-**

**p1 –> next = p2**, p1 stores address of p2 which forms a link.

In this way we formed linked list and stored data in it with address.

## Types of Linked List

**Operations on linked list**

**1. Insert at beginning**

This operation state that to insert node at beginning of linked list.

Example:- Insert 10 at beginning.

Insert 7 at beginning.

Before adding node to beginning it is start node but after adding at beginning new node become start.

**2. Insert at end**

This operation is to add new node at last of LL.

Add 10 at end of LL.

After adding node at end null be replaced by address of new node.

**3. Insert before**

This operation is to add new node before any previous given node.

Add 15 before 20 value in LL.

After adding new node we have to modify address of previous node and add that to new node added.

**4. Deletion of node**

This operation is to delete modes of the LL.

**5. Destory**

To delete complete LL.