Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Data Structure and Algorithm lhs Algornithens (2018-07 Onsite) of each node cont

ID: 3917177 • Letter: D

Question

Data Structure and Algorithm

lhs Algornithens (2018-07 Onsite) of each node containing an integer, and next except the one in the last node which has the value NULL. Write a data field containing a given value val, if it exists. tirst, the data field the next node in the list, function to delete the node with the nodes in a linked list with the first node pointed to by first, the data field of each node pointing to data data ext first

Explanation / Answer

C++: ----- void remove(int val) { if(first != NULL) { if(first->data == val) { first = first->next; } else { Node *temp = first; while(temp->next != NULL) { if(temp->next->data == val) { Node *d = temp->next; temp->next = temp->next->next; delete d; break; } temp = temp->next; } } } }