0% found this document useful (0 votes)
8 views

Shorted DLL

Uploaded by

gosalacharvi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Shorted DLL

Uploaded by

gosalacharvi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

#include<stdio.

h>

#include<stdlib.h>

struct node {

struct node *next;

struct node *prev;

int data;

};

struct node *head=NULL;

void create();

void insert_begin();

void insert_after();

void insert_end();

void delete_begin();

void delete_info();

void delete_end();

void display();

void main()

int ch;

system("clear");

while(1)

printf("\n1.create the list");

printf("\n2.insert at beginning");

printf("\n3.insert after location");

printf("\n4.insert at end");

printf("\n5.delete at beginnig");

printf("\n6. delete specific node");

printf("\n7.delete at end");

printf("\n8. display");

printf("\n.9 exit(0)");
printf("enetr your choice\n");

scanf("%d",&ch);

switch(ch)

case 1:create();break;

case 2:insert_begin();break;

case 3:insert_after();break;

case 4:insert_end();break;

case 5:delete_begin();break;

case 6:delete_info(); break;

case 7:delete_end(); break;

case 8:display();break;

case 9:exit(0);break;

default: printf("entered wrong choice");

void create(){

int c;

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

printf("enter first nodeinformation");

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

ptr->prev=NULL;

ptr->next=NULL;

head=ptr;

printf("enter 0/1 for more nodes");

scanf("%d",&c);

while(c==1)

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


printf("enter next node information");

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

ptr->next=cptr;

cptr->prev=ptr;

cptr->next=NULL;

ptr=cptr;

printf("enter 0/1 for more nodes");

scanf("%d",&c);

void insert_begin()

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

printf("enter node information");

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

ptr->next=head;

ptr->prev=NULL;

head->prev=ptr;

head=ptr;

printf("node inserted");

void insert_end()

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

printf("enter node information");

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

struct node *temp=head;

while(temp->next!=NULL)
{

temp=temp->next;

ptr->next=NULL;

ptr->prev=temp;

temp->next=ptr;

printf("node inserted\n");

void insert_after()

struct node *ptr,*temp;

ptr=malloc(sizeof(struct node));

printf("enter node information");

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

temp=head;

int i,loc;

printf("enter location");

scanf("%d",&loc);

for(i=1;i<loc;i++)

temp=temp->next;

ptr->next=temp->next;

temp->next=ptr;

ptr->prev=temp;

printf("node inserted");

void delete_begin()
{

struct node *ptr;

ptr=head;

head=ptr->next;

head->prev=NULL;

free(ptr);

printf("node deleted");

void delete_info()

struct node *ptr,*temp;

ptr=head;

int i,loc;

printf("enter the location");

scanf("%d",&loc);

for(i=1;i<loc;i++)

temp=ptr;

ptr=ptr->next;

temp->next=ptr->next;

ptr->next->prev=temp;

free(ptr);

printf("node deleted");

void delete_end()

struct node *ptr,*temp;

ptr=head;

while(ptr->next!=NULL)
{

temp=ptr;

ptr=ptr->next;

temp->next=NULL;

free(ptr);

printf("node deleted");

void display()

struct node *ptr;

ptr=head;

while(ptr!=NULL)

printf("%d-->",ptr->data);

ptr=ptr->next;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy