diff --git a/Linked list/rotate-doublylinkedlist b/Linked list/rotate-doublylinkedlist new file mode 100644 index 0000000..56b7f98 --- /dev/null +++ b/Linked list/rotate-doublylinkedlist @@ -0,0 +1,71 @@ +#include +using namespace std; + +struct node +{ + int data; + struct node*next,*prev; +}; + +struct node* update(struct node*start,int p); + +int main() +{ + int t; + cin>>t; + while(t--) + { + int n,p; + cin>>n>>p; + struct node*start=NULL,*cur=NULL,*ptr=NULL; + for(int i=0;i>a; + ptr=new(struct node); + ptr->data=a; + ptr->next=NULL; + ptr->prev=NULL; + if(start==NULL) + { + start=ptr; + cur=ptr; + } + else + { + cur->next=ptr; + ptr->prev=cur; + cur=ptr; + } + } + struct node*str=update(start,p); + while(str!=NULL) + { + cout<data<<" "; + str=str->next; + } + cout<next!=NULL) + { + temp = temp->next ; + } + node* s= start ; + for(int i=0;inext ; + temp->next = t ; + t->prev = temp ; + temp=temp->next ; + t->next = NULL ; + } + return s ; +} +