hi,
can someone understand how the new element is being attached to the list in this code?
void insertSortedList (Node **head, int value)
{
/* creating a new node */
Node *ptr = createNode (value);
Node **pCurrent = head;
/* adding the new node to the correct place in the list */
while (*pCurrent != NULL && (*pCurrent)->val < ptr->val)
pCurrent = &( (*pCurrent)->next );
ptr->next = *pCurrent;
*pCurrent = ptr;
}
I refer spcifically to the last two lines.
thanks