Slip 30_2 : Write a program that merges two ordered linked lists into third new list. When two lists are merged the data in the resulting list are also ordered. The two original lists should be left unchanged. That is merged list should be new one. Use linked implementation.
Solution : #include<stdio.h> struct node { int data; struct node *next; }; struct node* create(); void display(struct node*); struct node* create() { int n,i; struct node *s,*f; printf("Enter how many nodes "); scanf("%d",&n); f= (struct node *)malloc(sizeof(struct node)); printf("Enter data "); scanf("%d",&f->data); s=f; for(i=1;i<n;i++) { s->next=(struct node*)malloc(sizeof(struct node)); s=s->next; printf("Enter data "); scanf("%d",&s->data); } s->next=NULL; return f; } void display(struct node *f) { struct node *s; for(s=f;s!=NULL;s=s->next) { printf("| %d |-> ",s->data); } } struct node* merge(struct node *f1,struct node *f2) { struct node *s; for(s=f1;s->next!=NULL;s=s->next) { } s->next=f2; return f1; } main() { ...