Question: Implement a helper function for the LinkedList class : void LinkedList::removeAfter(Node * pre) The job of this function is to remove the node right after

Implement a helper function for the LinkedList class :

void LinkedList::removeAfter(Node * pre)

The job of this function is to remove the node right after pre. (You can assume that pre and pre->next are not null.) The function should also decrement length since the linked list will be one node shorter than before the function was called.

Remember: to remove the node after pre you need to save the node's address in a temp variable , then set pre->next to temp->next. Finally you should delete temp and decrement length.

The function will be a helper function for removeValue and removeAtPosition. That means you are allowed to call it when you implement those functions.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!