#include #include #include #include struct node{ struct node*prev; int info; struct node*next; }*head,*p,*q,*temp; struct node * createnode() { temp=new(struct node); cout<<"Enter Info Part "; cin>>temp->info; temp->next=temp->prev=NULL; return(temp); } void print_reverse() { struct node *i=head; while(i->next!=NULL) i=i->next; struct node * tail = i; cout <prev!=NULL) { cout<info<<" "; tail=tail->prev; } cout<info; } void insert_beg() { temp=createnode(); if(head==NULL) head=temp; else { temp->next=head; head->prev=temp; head=temp; } } void display() { struct node *i; cout<<"My List is"<next) cout<info<<" "; } void search() { struct node *i; int pos,ele,found=0; cout<<"Enter element to search:"; cin>>ele; pos=1; for(i=head;i!=NULL;i=i->next,pos++) { if(i->info==ele) { cout<<"Element found at "<next; p->next=t; t=p; p=q; } head=t; } void insert_end() { struct node *i; temp=createnode(); if(head==NULL) head=temp; else { for(i=head;i->next!=NULL;i=i->next) ; i->next=temp; temp->prev=i; } } void insert_pos() { int j,pos; struct node *i; cout<<"At which position : " ; cin>>pos; temp=createnode(); i=head; for(j=1;jnext; } p->next=temp; temp->prev=p; temp->next=i; i->prev=temp; } void delete_pos() { int pos; cout<<"Enter Position:"; cin>>pos; if(pos==1) head=head->next; else { p=head; for(int i=1;inext; } q->next=p->next; (p->next)->prev=q; } } void delete_last() { p=head; while(p->next!=NULL) { q=p; p=p->next; } q->next=NULL; delete(p); } void main() { int choice; clrscr(); do { cout<>choice; switch(choice) { case 1:insert_beg();break; case 2:display();break; case 3:insert_end();break; case 4:insert_pos();break; case 5:delete_pos();break; case 6:delete_last();break; case 7:search();break; case 8:reverse();break; case 9:print_reverse();break; case 10:exit(0); } }while(choice!=10); }