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 firstExplanation / 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; } } } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.