This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct node | |
{ | |
int data; | |
struct node *next; | |
}; | |
struct node* SortedMerge(struct node *a, struct node *b) | |
{ | |
struct node *result; | |
if(a == NULL) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Make an interating pointer that goes forward every time till the end, and then jumps to the beginning of the opposite list, and so on. Create two of these, pointing to two heads. Advance each of the pointers by 1 every time, until they meet.*/ | |
int FindMergeNode(Node *headA, Node *headB) | |
{ | |
Node *p1 = headA; | |
Node *p2 = headB; | |
while(p1 != p2){ | |
p1 = p1->next; | |
p2 = p2->next; | |
if(p1 == NULL) | |
p1 = headB; |