Void merge (slnodetype * headA, slnodestype * headB)
{
Slnodetype * tempA, * tempB, * temp;
TempA = headA;
TempB = headB;
// Loop the elements in each A and put the elements in B that are smaller than the elements in A before them.
While (tempA-> next! = HeadA)
{
Temp = tempA;
// Loop the elements in B and place the elements in B smaller than the elements in A before the elements in
While (tempA-> next-> data> tempB-> next-> data)
{
Temp-> next = tempB-> next;
TempB-> next = tempA-> next;
Temp = tempB-next;
// Elements in the next B;
TempB = tempB-> next;
If (tempB-> next = headB & tempA-next = headA)
{
// When the end of a or B is reached, the combination is completed and the header node of B is released.
Free (headB)
Return;
}
}
// ELEMENTS IN THE NEXT
TempA = temp-> next;
}
// Find the tail element of B
While (tempB-> next! = HeadB)
{
TempB = tempB-> next;
}
// Add the elements at the end of B to the front of A, release the header node of B, and complete the combination.
TempB-> next = headA;
Free (headB );
}
Typedef struct slnode
{
Elemtype data;
Struct slnode * next;
} Slnodetype;
/* Think that a good algorithm is very important to improve the program performance. Please give me more advice for the first time */