CREAT A LINKLIST(single)
#include<stdio.h>
#include<stdlib.h>
struct NODE{
int data;
struct NODE* next;
};
void print(struct NODE* head){
struct NODE* temp=head;
while(temp!=NULL){
printf("%d->",temp->data);
temp=temp->next;
int main(){
struct NODE* head=(struct NODE*)malloc(sizeof(struct NODE));
struct NODE* current=(struct NODE*)malloc(sizeof(struct NODE));
struct NODE* ptr=(struct NODE*)malloc(sizeof(struct NODE));
head->data=10;
current->data=20;
ptr->data=30;
head->next=current;
current->next=ptr;
ptr->next=NULL;
print(head);
return 0;
}
Insert Node First
#include<stdio.h>
#include<stdlib.h>
struct NODE{
int data;
struct NODE* next;
};
struct NODE *add(struct NODE *head,int d){
struct NODE *temp=(struct NODE*)malloc(sizeof(struct NODE));
temp->data=d;
temp->next=head;
head=temp;
return head;
};
int main(){
struct NODE *head=NULL,*current=NULL,*ptr=NULL;
head= (struct NODE*)malloc(sizeof(struct NODE));
current=(struct NODE*)malloc(sizeof(struct NODE));
ptr=(struct NODE*)malloc(sizeof(struct NODE));
head->data=20;
current->data=30;
ptr->data=40;
head->next=current;
current->next=ptr;
ptr->next=NULL;
int d=10;
head=add(head,d);
while(head!=NULL){
printf("%d->",head->data);
head=head->next;
return 0;
}
Insert Node First(DOUBLE)
#include<stdio.h>
#include<stdlib.h>
struct NODE{
int data;
struct NODE* next;
struct NODE* prev;
};
struct NODE *add(struct NODE *head,int d){
struct NODE *temp=(struct NODE*)malloc(sizeof(struct NODE));
temp->data=d;
temp->prev=NULL;
temp->next=head;
head->prev=temp;
head=temp;
return head;
};
int main(){
struct NODE *head=NULL,*current=NULL,*ptr=NULL;
head= (struct NODE*)malloc(sizeof(struct NODE));
current=(struct NODE*)malloc(sizeof(struct NODE));
ptr=(struct NODE*)malloc(sizeof(struct NODE));
head->data=20;
current->data=30;
ptr->data=40;
head->prev=NULL;
current->prev=head;
ptr->prev=current;
head->next=current;
current->next=ptr;
ptr->next=NULL;
int d=10;
head=add(head,d);
while(head!=NULL){
printf("%d <->",head->data);
head=head->next;
printf("NULL \n");
return 0;
Insart Node Last
#include<stdio.h>
#include<stdlib.h>
struct NODE{
int data;
struct NODE* next;
};
void add(struct NODE* head,int d){
struct NODE *ne=head,* temp=(struct NODE*)malloc(sizeof(struct NODE));
temp->data=d;
temp->next=NULL;
while(ne->next!=NULL){
ne=ne->next;
ne->next=temp;
int main(){
struct NODE *head=NULL,*current=NULL,*ptr=NULL;
head= (struct NODE*)malloc(sizeof(struct NODE));
current=(struct NODE*)malloc(sizeof(struct NODE));
ptr=(struct NODE*)malloc(sizeof(struct NODE));
head->data=20;
current->data=30;
ptr->data=40;
head->next=current;
current->next=ptr;
ptr->next=NULL;
int d=10;
add(head,d);
while(head!=NULL){
printf("%d->",head->data);
head=head->next;
return 0;
Insert Node Last(DOUBLE)
#include<stdio.h>
#include<stdlib.h>
struct NODE{
int data;
struct NODE* next;
struct NODE* prev;
};
void add(struct NODE* head,int d){
struct NODE *ne=head,* temp=(struct NODE*)malloc(sizeof(struct NODE));
temp->data=d;
temp->next=NULL;
while(ne->next!=NULL){
ne=ne->next;
ne->next=temp;
temp->prev=ne;
int main(){
struct NODE *head=NULL,*current=NULL,*ptr=NULL;
head= (struct NODE*)malloc(sizeof(struct NODE));
current=(struct NODE*)malloc(sizeof(struct NODE));
ptr=(struct NODE*)malloc(sizeof(struct NODE));
head->data=20;
current->data=30;
ptr->data=40;
head->prev=NULL;
current->prev=head;
ptr->prev=current;
head->next=current;
current->next=ptr;
ptr->next=NULL;
int d=10;
add(head,d);
while(head!=NULL){
printf("%d<->",head->data);
head=head->next;
printf("NULL");
return 0;
Insart Node Anywhere
#include<stdio.h>
#include<stdlib.h>
struct NODE{
int data;
struct NODE* next;
};
void add(struct NODE* head,int d){
struct NODE *ne=head,* temp=(struct NODE*)malloc(sizeof(struct NODE));
temp->data=d;
temp->next=NULL;
while(ne->data!=30){
ne=ne->next;
}
temp->next=ne->next;
ne->next=temp;
int main(){
struct NODE *head=NULL,*current=NULL,*ptr=NULL;
head= (struct NODE*)malloc(sizeof(struct NODE));
current=(struct NODE*)malloc(sizeof(struct NODE));
ptr=(struct NODE*)malloc(sizeof(struct NODE));
head->data=20;
current->data=30;
ptr->data=40;
head->next=current;
current->next=ptr;
ptr->next=NULL;
int d=10;
add(head,d);
while(head!=NULL){
printf("%d->",head->data);
head=head->next;
return 0;
Insart Node Anywhere(DOUBLE)
#include<stdio.h>
#include<stdlib.h>
struct NODE{
int data;
struct NODE* next;
struct NODE* prev;
};
void add(struct NODE* head,int d){
struct NODE *ne=head,* temp=(struct NODE*)malloc(sizeof(struct NODE));
temp->data=d;
temp->next=NULL;
while(ne->data!=30){
ne=ne->next;
temp->prev=ne;
temp->next=ne->next;
ne->next=temp;
int main(){
struct NODE *head=NULL,*current=NULL,*ptr=NULL;
head= (struct NODE*)malloc(sizeof(struct NODE));
current=(struct NODE*)malloc(sizeof(struct NODE));
ptr=(struct NODE*)malloc(sizeof(struct NODE));
head->data=20;
current->data=30;
ptr->data=40;
head->prev=NULL;
current->prev=head;
ptr->prev=current;
head->next=current;
current->next=ptr;
ptr->next=NULL;
int d=10;
add(head,d);
while(head!=NULL){
printf("%d<->",head->data);
head=head->next;
printf("NULL");
return 0;
DELET NODE FIRST
#include<stdio.h>
#include<stdlib.h>
struct NODE{
int data;
struct NODE* next;
};
struct NODE *delet(struct NODE *head){
struct NODE *temp=head;
if(temp->next==NULL){
printf("THE LIST IS EMPTY!");
}else{
struct NODE* p=temp;
temp=temp->next;
free(p);
head=temp;
return head;
};
int main(){
struct NODE *head=NULL,*current=NULL,*ptr=NULL;
head= (struct NODE*)malloc(sizeof(struct NODE));
current=(struct NODE*)malloc(sizeof(struct NODE));
ptr=(struct NODE*)malloc(sizeof(struct NODE));
head->data=20;
current->data=30;
ptr->data=40;
head->next=current;
current->next=ptr;
ptr->next=NULL;
head=delet(head);
while(head!=NULL){
printf("%d->",head->data);
head=head->next;
return 0;
DELET NODE FIRST(DOUBLE)
#include<stdio.h>
#include<stdlib.h>
struct NODE{
int data;
struct NODE* next;
struct NODE* prev;
};
struct NODE *delet(struct NODE *head){
struct NODE *temp=head;
if(temp->next==NULL){
printf("THE LIST IS EMPTY!");
}else{
struct NODE* p=temp;
temp=temp->next;
free(p);
p=NULL;
temp->prev=NULL;
head=temp;
return head;
};
int main(){
struct NODE *head=NULL,*current=NULL,*ptr=NULL;
head= (struct NODE*)malloc(sizeof(struct NODE));
current=(struct NODE*)malloc(sizeof(struct NODE));
ptr=(struct NODE*)malloc(sizeof(struct NODE));
head->data=20;
current->data=30;
ptr->data=40;
head->prev=NULL;
current->prev=head;
ptr->prev=current;
head->next=current;
current->next=ptr;
ptr->next=NULL;
head=delet(head);
while(head!=NULL){
printf("%d<->",head->data);
head=head->next;
printf("NULL");
return 0;
DELET NODE LAST
#include<stdio.h>
#include<stdlib.h>
struct NODE{
int data;
struct NODE* next;
};
struct NODE *delet(struct NODE *head){
struct NODE *temp=head;
if(temp->next==NULL){
printf("THE LIST IS EMPTY!");
}else{
struct NODE* temp1=temp;
struct NODE* temp2=temp;
while(temp2->next!=NULL){
temp1=temp2;
temp2=temp2->next;
temp1->next=NULL;
free(temp2);
head=temp;
return head;
};
int main(){
struct NODE *head=NULL,*current=NULL,*ptr=NULL;
head= (struct NODE*)malloc(sizeof(struct NODE));
current=(struct NODE*)malloc(sizeof(struct NODE));
ptr=(struct NODE*)malloc(sizeof(struct NODE));
head->data=20;
current->data=30;
ptr->data=40;
head->next=current;
current->next=ptr;
ptr->next=NULL;
head=delet(head);
while(head!=NULL){
printf("%d->",head->data);
head=head->next;
return 0;
DELET NODE LAST(DOUBLE)
#include<stdio.h>
#include<stdlib.h>
struct NODE{
int data;
struct NODE* next;
struct NODE* prev;
};
struct NODE *delet(struct NODE *head){
struct NODE *temp=head;
if(temp->next==NULL){
printf("THE LIST IS EMPTY!");
}else{
struct NODE* p=temp;
temp=temp->next;
free(p);
p=NULL;
temp->prev=NULL;
head=temp;
return head;
};
int main(){
struct NODE *head=NULL,*current=NULL,*ptr=NULL;
head= (struct NODE*)malloc(sizeof(struct NODE));
current=(struct NODE*)malloc(sizeof(struct NODE));
ptr=(struct NODE*)malloc(sizeof(struct NODE));
head->data=20;
current->data=30;
ptr->data=40;
head->prev=NULL;
current->prev=head;
ptr->prev=current;
head->next=current;
current->next=ptr;
ptr->next=NULL;
head=delet(head);
while(head!=NULL){
printf("%d<->",head->data);
head=head->next;
printf("NULL");
return 0;
DELET PARTICULAR NODE
#include<stdio.h>
#include<stdlib.h>
struct NODE{
int data;
struct NODE* next;
};
struct NODE *delet(struct NODE *head){
struct NODE *temp=head;
if(temp->next==NULL){
printf("THE LIST IS EMPTY!");
}else{
struct NODE* temp1=temp;
struct NODE* temp2=temp;
while(temp2->data!=40){
temp1=temp2;
temp2=temp2->next;
temp1->next=temp2->next;
free(temp2);
head=temp;
return head;
};
int main(){
struct NODE *head=NULL,*current=NULL,*ptr=NULL,*top=NULL;
head= (struct NODE*)malloc(sizeof(struct NODE));
current=(struct NODE*)malloc(sizeof(struct NODE));
ptr=(struct NODE*)malloc(sizeof(struct NODE));
top=(struct NODE*)malloc(sizeof(struct NODE));
head->data=20;
current->data=30;
ptr->data=40;
top->data=50;
head->next=current;
current->next=ptr;
ptr->next=top;
top->next=NULL;
head=delet(head);
while(head!=NULL){
printf("%d->",head->data);
head=head->next;
return 0;
DELET PARTICULAR NODE(DOUBLE)
#include<stdio.h>
#include<stdlib.h>
struct NODE{
int data;
struct NODE* next;
struct NODE* prev;
};
struct NODE *delet(struct NODE *head){
struct NODE *temp=head;
if(temp->next==NULL){
printf("THE LIST IS EMPTY!");
}else{
struct NODE* temp1=temp;
struct NODE* temp2=temp;
while(temp2->data!=40){
temp1=temp2;
temp2=temp2->next;
temp1->next=temp2->next;
temp2->prev=NULL;
free(temp2);
head=temp;
return head;
};
int main(){
struct NODE *head=NULL,*current=NULL,*ptr=NULL,*top=NULL;
head= (struct NODE*)malloc(sizeof(struct NODE));
current=(struct NODE*)malloc(sizeof(struct NODE));
ptr=(struct NODE*)malloc(sizeof(struct NODE));
top=(struct NODE*)malloc(sizeof(struct NODE));
head->data=20;
current->data=30;
ptr->data=40;
top->data=50;
head->prev=NULL;
current->prev=head;
ptr->prev=current;
top->prev=ptr;
head->next=current;
current->next=ptr;
ptr->next=top;
top->next=NULL;
head=delet(head);
while(head!=NULL){
printf("%d<->",head->data);
head=head->next;
printf("NULL");
return 0;
CIRCULAR LINKLIST(Singly)
#include<stdio.h>
#include<stdlib.h>
struct NODE{
int data;
struct NODE* next;
};
void print(struct NODE* head,int n){
struct NODE* p=head;
struct NODE* temp=head;
do{
printf("%d->",temp->data);
temp=temp->next;
}while(
temp->next!=p->next
);
int main(){
struct NODE* head=(struct NODE*)malloc(sizeof(struct NODE));
struct NODE* current=(struct NODE*)malloc(sizeof(struct NODE));
struct NODE* ptr=(struct NODE*)malloc(sizeof(struct NODE));
head->data=10;
current->data=20;
ptr->data=30;
head->next=current;
current->next=ptr;
ptr->next=head;
int NUMBEROFNODE=3;
print(head,NUMBEROFNODE);
return 0;