58
Double Linked List #include<stdio.h> #include<conio.h> #include<process.h> #include<alloc.h> struct node { int data; struct node *prev,*next; }*start=NULL,*p,*q, *r, *New; int item, pos, c=0, i;

Double linked list

Embed Size (px)

DESCRIPTION

DLL Practicals

Citation preview

Page 1: Double linked list

Double Linked List#include<stdio.h>

#include<conio.h>

#include<process.h>

#include<alloc.h>

struct node

{

int data;

struct node *prev,*next;

}*start=NULL,*p,*q, *r, *New;

int item, pos, c=0, i;

Page 2: Double linked list

Double Linked Listvoid main()

{

int ch;

clrscr();

do

{

printf("\n***MENU***");

printf("\n1.Insert\n2.Delete\n3.Search\n4.Display\n5.Exit");

printf("\nPlease Enter the choice...");

scanf("%d",&ch); 1

switch(ch)

{

case 1:insert();break;

case 2:del();break;

case 3:search();break;

case 4:disp();break;

case 5:exit(0);

default:printf("\nInvalid Choice...\n");

}

}while(ch!=5);

getch();

}

Page 3: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos); 1

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

New

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ \

Page 4: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data); 10

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

New

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 \

Page 5: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

New

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 \

Page 6: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start = NULL

New

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 \

Page 7: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start = NULL

New

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 \

Page 8: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

c = 0 + 1

New,

start

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 \

Page 9: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

c = 0 + 1

New,

start

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("Data Inserted Successfully );

}

else

printf("\n Invalid Position...\n");

}

\ 10 \

Page 10: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos); 2

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start New

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 \ \ \

Page 11: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data); 20

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start New

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 \ \ 20 \

Page 12: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start New

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 \ \ 20 \

Page 13: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start New

p

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 \ \ 20 \

Page 14: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start New

p

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 \ \ 20 \

Page 15: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

q = NULL

start New

p

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 \ \ 20 \

Page 16: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

q = NULL

start New

p

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 \ \ 20 \

Page 17: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

q = NULL

start New

p

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 \ 20 \

Page 18: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

q = NULL

start New

p

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("Data Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 20 \

Page 19: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos); 2

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start

New

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 20 \

\ 15 \

Page 20: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data); 15

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start

New

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 20 \

\ 15 \

Page 21: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start

New

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 20 \

\ 15 \

Page 22: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start

P

New

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 20 \

\ 15 \

Page 23: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start

P

New

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

\ 10 20 \

\ 15 \

Page 24: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start

pNew

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

q

\ 10 20 \

\ 15 \

Page 25: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start

pNew

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

q

\ 10 20 \

\ 15

Page 26: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start

pNew

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

q

\ 10 20 \

15

Page 27: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start

pNew

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

q

\ 10 20 \

15

Page 28: Double linked list

void insert()

{

printf("\nEnter the position where to insert...");

scanf("%d",&pos);

New=(struct node *)malloc(sizeof(struct node));

New->prev=New->next=NULL;

if(pos<=c+1)

{

printf("\nEnter the data to be inserted...");

scanf("%d",&New->data);

if(pos==1)

{

New->next=start;

start->prev=New;

start=New;

c++;

}

start

pNew

else

{

p=start;

for(i=1;i<pos-1;i++)

p=p->next;

q = p->next;

New->next=q; New->prev=p;

p->next=New;

q->prev=New;

c++;

}

printf("\nData Inserted Successfully );

}

else

printf("\nInvalid Position...\n");

}

q

\ 10 20 \

15

Page 29: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \ 15

Page 30: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item); 15

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \ 15

Page 31: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

p

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \ 15

Page 32: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

p

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \ 15

Page 33: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

p

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \ 15

Page 34: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

p

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \ 15

Page 35: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

p

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \ 15

Page 36: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

p

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \ 15

Page 37: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

p

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

q

\ 10 20 \ 15

Page 38: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

r p

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

q

\ 10 20 \ 15

Page 39: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

r p

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

q

\ 10 20 \ 15

Page 40: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

r p

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

q

\ 10 20 \ 15

Page 41: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \

Page 42: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item); 10

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \

Page 43: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

p

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \

Page 44: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

p

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \

Page 45: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

p

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \

Page 46: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

p

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \

Page 47: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

p start

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 20 \

Page 48: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

p start

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 10 \ 20 \

Page 49: Double linked list

void del()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Data to be Deleted...\n");

scanf("%d",&item);

p=start;

while(p!=NULL&&p->data!=item)

p=p->next;

if(p==NULL)

{

printf("\nData is not found...\n");

return;

}

start

if(p->prev==NULL)

{

start=start->next;

start->prev=NULL;

}

else

{

q = p->next;

r = p->prev;

r->next = q;

q->prev = r;

}

c--;

printf("%d is Deleted...\n",p->data);

free(p);

}

\ 20 \

Page 50: Double linked list

void search()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Item to be Searched...");

scanf("%d",&item);

p=start;

start

while(p!=NULL)

{

if(item==p->data)

{

printf("Data is Found...\n");

break;

}

p=p->next;

}

if(p==NULL)

printf("\nData is not Found...\n");

}

\ 10 20 \ 15

Page 51: Double linked list

void search()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Item to be Searched...");

scanf("%d",&item); 15

p=start;

start

while(p!=NULL)

{

if(item==p->data)

{

printf("Data is Found...\n");

break;

}

p=p->next;

}

if(p==NULL)

printf("\nData is not Found...\n");

}

\ 10 20 \ 15

Page 52: Double linked list

void search()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Item to be Searched...");

scanf("%d",&item);

p=start;

start

p

while(p!=NULL)

{

if(item==p->data)

{

printf("Data is Found...\n");

break;

}

p=p->next;

}

if(p==NULL)

printf("\nData is not Found...\n");

}

\ 10 20 \ 15

Page 53: Double linked list

void search()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Item to be Searched...");

scanf("%d",&item);

p=start;

start

p

while(p!=NULL)

{

if(item==p->data)

{

printf("Data is Found...\n");

break;

}

p=p->next;

}

if(p==NULL)

printf("\nData is not Found...\n");

}

\ 10 20 \ 15

Page 54: Double linked list

void search()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Item to be Searched...");

scanf("%d",&item);

p=start;

start

p

while(p!=NULL)

{

if(item==p->data)

{

printf("Data is Found...\n");

break;

}

p=p->next;

}

if(p==NULL)

printf("\nData is not Found...\n");

}

\ 10 20 \ 15

Page 55: Double linked list

void search()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Item to be Searched...");

scanf("%d",&item);

p=start;

start

while(p!=NULL)

{

if(item==p->data)

{

printf("Data is Found...\n");

break;

}

p=p->next;

}

if(p==NULL)

printf("\nData is not Found...\n");

}

p

\ 10 20 \ 15

Page 56: Double linked list

void search()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Item to be Searched...");

scanf("%d",&item);

p=start;

start

while(p!=NULL)

{

if(item==p->data)

{

printf("Data is Found...\n");

break;

}

p=p->next;

}

if(p==NULL)

printf("\nData is not Found...\n");

}

p

\ 10 20 \ 15

Page 57: Double linked list

void search()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Item to be Searched...");

scanf("%d",&item);

p=start;

start

while(p!=NULL)

{

if(item==p->data)

{

printf("Data is Found...\n");

break;

}

p=p->next;

}

if(p==NULL)

printf("\nData is not Found...\n");

}

p

\ 10 20 \ 15

Page 58: Double linked list

void search()

{

if(start==NULL)

{

printf("\nList is Empty...\n");

return;

}

printf("\nEnter the Item to be Searched...");

scanf("%d",&item);

p=start;

start

while(p!=NULL)

{

if(item==p->data)

{

printf("Data is Found.\n");

break;

}

p=p->next;

}

if(p==NULL)

printf("\nData is not Found...\n");

}

p

\ 10 20 \ 15