Appending a Linked List to Another
[wpdm_package id=’1177′]
Appending a linked list onto another is pretty easy. All you have to do is, make the last node’s next pointer of the first list to point to the head of the second list, as shown. But in the upcoming posts, we can find more advanced changes like, returning a sorted list after appending a sorted list to another sorted list, and so on.
[sourcecode lang=”cpp”]
void append_list(intnode * head1) {
intnode* temp;
for(temp=head;temp->next!=NULL;temp=temp->next);
temp->next=head1;
}
[/sourcecode]