# What is below function doing?
Note: we assume the memory for the new node has already been allocated and a pointer to that memory is being passed to this function. Also assume that the linked list will be already in sorted order?
// Special case code for the head end
void linkedListFun(struct node** headReference, struct node* newNode)
{
// Special case for the head end
if (*headReference == NULL || (*headReference)->data >= newNode->data)
{
newNode->next = *headReference;
*headReference = newNode;
}
else
{
// Locate the node before which the insertion is to happen!
struct node* current = *headReference;
while (current->next!=NULL && current->next->data < newNode->data)
{
current = current->next;
}
newNode->next = current->next;
current->next = newNode;
}
}