Here is a linked list where pList points to the node containing the value 3
pList
|
3 7 6 1 2 8 4 5 -> NULL
Given the following code, redraw the list showing the changes to the list after the following code is executed.
pCur = pList;
while(pCur->next->next != NULL)
pCur = pCur->next;
pCur->next->next = pList;
pList = pCur -> next;
pCur -> next = NULL;
pCur = NULL;
Here is my interpretation of what is happening: pCur = pList (pCur = pList) | 3 7 6 1 2 8 4 5 -> NULL
pList pCur (pCur = pCur->next)
| |
3 7 6 1 2 8 4 5 -> NULL
pCur PList (pCur->next->next = pList)
| |
3 7 6 1 2 8 4 5 -> NULL
pCur pList (pList = pCur->next)
| |
3 7 6 1 2 8 4 5 -> NULL
(pCur->next = NULL)
3 7 6 1 2 8 -> NULL
I don't believe this is correct. What am I doing wrong?