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

49. What is wrong with this definition of the List erase function? iterator List

ID: 3902370 • Letter: 4

Question

49. What is wrong with this definition of the List erase function? iterator List: :erase (lterat r iter) assert (iter.position !- NULL); Node* remove-iter.position; Node* beforeremove->previous; N de * after = remove->next; if (remove first) first after; last = before ; after->previousbefore; if (remove last) else delete remove; Iterator r; r.position after; r. container-this; return r; a) The before pointer should be set to the after node after the condition if (remove = first) b) The before->ext pointer should be set to the after node after the condition if (remove c The before->previous pointer should be set to the after node after the condition if d) There is no problem with the erase function. first) (remove == first)

Explanation / Answer

b. The before->next should point to after.

So that list will be continuous after erasing r from list.

Code should be:

before->next=after;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote