three cases can occur when inserting node into sorted linked listas illustrated in figure the node is inserted in the frontat the endor somewhere in the middle after finding the correct positiona new node is created and its next field is changed to point to the same node referenced by curnode this link is required no matter where in the list the new node is inserted if the new node is to be inserted in the frontthen the operation is simple prependas was done with an unsorted linked listand curnode will be pointing to the first node when the new value being added is the largest in the list and the new node is to be added at the endcurnode will be null and thus the next field will be null as it should be when the new node is inserted elsewhere in the listcurnode will be pointing to the node that will follow the new node after linking the new node to the listwe must determine if it is being inserted at the front of the listin which case the head reference must be adjusted we do this by comparing the curnode reference with the head reference if they are aliasesthe new node comes first in the linked list and we must adjust the head head newnode - (ahead prednode curnode newnode (bhead prednode curnode newnode (cfigure inserting new value into sorted linked list(ainserting - at the front of the list(binserting in the middle of the list(cinserting at the end of the list