Question: Delete the last node of the Linked List //Delete last node of the list void pop_back() {// Check if there is LL if(head != NULL)

Delete the last node of the Linked List

//Delete last node of the list void pop_back() {// Check if there is LL if(head != NULL) {// if only one node if(head->next == NULL) { head = NULL;} // more than one nodeelse { Node* temp = head; while(temp->next->next != NULL){ temp = temp->next;} temp->next = NULL; } }

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!