can i have c++ program for cyclic shifts using circular linked lists Solution #
ID: 3666320 • Letter: C
Question
can i have c++ program for cyclic shifts using circular linked lists
Explanation / Answer
# include # include # include # include int cur_link_list=1; int display_menu(); struct link_list { int no; struct link_list *next; }; class link { link_list *list; public: link_list *head; link() { list=NULL; head=NULL; } void get_list(); void display_list(); void insert(); void delete_list(); void sort(); void merge(link_list *,link_list*); friend void union_list(link_list *,link_list *); friend void intersact(link_list *,link_list *); void reverse(); }; void link :: get_list() { int no; if(head!=NULL) { while(list->next!=head) { delete(list); list=list->next; } list=NULL; head=NULL; } while(1) { coutno; if(no!=0) { if(list==NULL) { list=new link_list; head=list; } list->no=no; list->next = new link_list; list=list->next; } else { list->next=head; break; } } } void link :: display_list() { list=head; coutnext=list->next->next; return; } list=list->next; } coutnext) { for(j=head;j->next!=head;j=j->next) { if(i->no no) { t->no=i->no; i->no=j->no; j->no=t->no; } } } } void union_list(link_list *l1,link_list *l2) { coutno==l2->no) { flag=1; break; } l1=l1->next; } if(flag==0) { coutnext!=h) { if(l1->no==l2->no) { coutnext!=head) { a[i]=list->no; list=list->next; i=i+1; } int n=i-1; i=n; list=head; while(list->next!=head) { list->no=a[i]; list=list->next; i=i-1; } } void link :: merge(link_list *l1,link_list *l2) { link_list *head1,*head2; head1=l1; head2=l2; head=NULL; list=new link_list; while(l1->next !=head1) { if(head==NULL) { head=list; } list->no=l1->no; list->next=new link_list; list=list->next; l1=l1->next; list->next=head; } while(l2->next !=head2) { list->no=l2->no; list->next=new link_list; list=list->next; l2=l2->next; list->next=head; } list->next=head; } void main() { clrscr(); link l1,l2,l3; while(1) { switch(display_menu()) { case 1: coutn; if(n>=1 && nRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.