after the midpoint is locatedthe link between the node referenced by midpoint and its successor can be removedcreating two sublistsas illustrated in figure before the link is removeda new head reference rightlist has to be created and initialized to reference the first node in the right sublist the rightlist head reference is returned by the function to provide access to the new sublist sublist midpoint rightlist curnode (asublist midpoint rightlist curnode (bfigure splitting the list after finding the midpoint(alink modifications required to unlink the last node of the left sublist from the right sublist and (bthe two sublists resulting from the split merging the lists the mergelinkedlists(functionprovided in lines - of listing manages the merging of the two sorted linked lists in we discussed an efficient solution for the problem of merging two sorted python listsand earlier in this that algorithm was adapted for use with arrays the array and python list versions are rather simple since we can refer to individual elements by index and easily append the values to the sequence structure merging two sorted linked lists requires several modifications to the earlier algorithm firstthe nodes from the two sublists will be removed from their respective list and appended to new sorted linked list we can use tail reference with the new sorted list to allow the nodes from the sublists to be appended in ( time secondafter all of the nodes have been removed from one of the two sublistswe do not have to iterate through the other list to append the nodes insteadwe can simply link the last node of the new sorted list to the first node in the remaining sublist finallywe can eliminate the special case of appending