Question: Consider a linked list with dummy header node. The variable head of type node* points to the dummy node. Suppose the value 30 appears in
Consider a linked list with dummy header node. The variable head of type node* points to the dummy node. Suppose the value 30 appears in the list. Consider the following code:
node* prev = head;
node* curr = head -> next;
while (curr -> data != 30) {
prev = curr;
curr = curr -> next;
}
Which of the following should be added after the end of the while loop to delete the node containing 30?
| a. | curr -> next = prev -> next; delete curr; | |
| b. | prev = curr -> next; delete curr; | |
| c. | prev -> next = curr -> next; delete curr; | |
| d. | curr = prev -> next; delete curr; |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
