Head->5->3->7->9->1->Null
TASK :
Node * prev = head ->next;
Node* nodeToInsert = new Node;
nodeToInsert-> data = 4;
nodeToInsert -> next = prev -> next;
prev -> next = nodeToInsert;
(1)Assume that the code represented above in part has executed.
What is the value of prev->data
(2)In addition to the code above, assume the following code executes. Draw a diagram of the list after
this code executes as well.
prev = prev -> next;
Node * curr = prev -> next;
prev -> next = curr -> next;
delete curr;
curr = NULL;
(1)
head->5->3->4->7->9->1->null
prev->datahas value 3
(2)
Comments
Leave a comment