struct node * merge2LinkedLists(struct node *head1, struct node *head2) { int count = 0; struct node *temp, *temp1,*result=NULL; temp = head1; temp1 = head2; if (temp == NULL && temp1 == NULL) return NULL; else if (temp == NULL) return temp1; else if (temp1 == NULL) return temp; else { if (temp->num <= temp1->num) { result = temp; result->next = merge2LinkedLists(temp->next, temp1); } else { result = temp1; result->next = merge2LinkedLists(temp, temp1->next); } return result; } }
struct node * merge2LinkedLists(struct node *h1, struct node *h2) { struct node *res = NULL; if (h1 == NULL)return h2; if (h2 == NULL)return h1; if (h1->num < h2->num) { res = h1; res->next = merge2LinkedLists(h1->next, h2); } else { res = h2; res->next = merge2LinkedLists(h1, h2->next); } return res; }
struct node * merge2LinkedLists(struct node *head1, struct node *head2) { struct node * temp = NULL; if (head1 == NULL) return head2; if (head2 == NULL) return head1; if (head1->num <= head2->num) { temp = head1; temp->next = merge2LinkedLists(head1->next, head2); } else { temp = head2; temp->next = merge2LinkedLists(head1, head2->next); } return temp; }
struct node * merge2LinkedLists(struct node *head1, struct node *head2) { struct node*temp1 = NULL, *curr,*temp2=NULL,*result=NULL; if (head1 == NULL && head2 == NULL) return NULL; if (head1 == NULL && head2 != NULL) return head2; if (head1 != NULL && head2 == NULL) return head1; if (head1->num < head2->num) { result = head1; result->next = merge2LinkedLists(head1->next, head2); } else { result = head2; result->next = merge2LinkedLists(head1, head2->next); } return result; }
struct node * merge2LinkedLists(struct node *head1, struct node *head2) { if (head1 == NULL&&head2 == NULL) return NULL; struct node* head3 = NULL; if (head1 == NULL) return head2; if (head2 == NULL) return head1; if (head1->num <= head2->num) { head3 = head1; head3->next = merge2LinkedLists(head2, head1->next); } else { head3 = head2; head3->next = merge2LinkedLists(head1, head2->next); } return head3; }
struct node * merge2LinkedLists(struct node *head1, struct node *head2) { if (head1 == NULL) return head2; else if (head2 == NULL) return head1; else { if (head1->num <= head2->num) { head1->next = merge2LinkedLists(head1->next, head2); return head1; } else { head2->next = merge2LinkedLists(head1, head2->next); return head2; } } }