Brijesh Patel
BAN USERstruct list{
int value;
struct listt *next;
}*temp,*p1,*p2,*final,*first_final;
struct list * merge(struct list *a,struct list *b)
{
if(a==NULL && b==NULL)
return NULL;
else if(a==NULL)
return b;
else if(b==NULL)
return a;
first_final=NULL;
if(a->value>b->value)
{
first_final=b;
b=b->next;
first_final->next=NULL;
temp=first_final;
}
else
{
first_final=a;
a=a->next;
first_final->next=NULL;
temp=first_final;
}
while(a!=NULL && b!=NULL)
{
//printf("Compared\n");
if(a->value>b->value)
{
temp->next=b;
temp=temp->next;
b=b->next;
temp->next=NULL;
}
else
{
temp->next=a;
temp=temp->next;
a=a->next;
temp->next=NULL;
}
}
if(a==NULL)
{
temp->next=b;
}
else if(b==NULL)
{
temp->next=a;
}
return first_final;
}
struct list{
- Brijesh Patel August 19, 2014int value;
struct listt *next;
}*temp,*p1,*p2,*final,*first_final;
struct list * merge(struct list *a,struct list *b)
{
if(a==NULL && b==NULL)
return NULL;
else if(a==NULL)
return b;
else if(b==NULL)
return a;
first_final=NULL;
if(a->value>b->value)
{
first_final=b;
b=b->next;
first_final->next=NULL;
temp=first_final;
}
else
{
first_final=a;
a=a->next;
first_final->next=NULL;
temp=first_final;
}
while(a!=NULL && b!=NULL)
{
//printf("Compared\n");
if(a->value>b->value)
{
temp->next=b;
temp=temp->next;
b=b->next;
temp->next=NULL;
}
else
{
temp->next=a;
temp=temp->next;
a=a->next;
temp->next=NULL;
}
}
if(a==NULL)
{
temp->next=b;
}
else if(b==NULL)
{
temp->next=a;
}
return first_final;
}