Question: The following code is a modification from section 5 . 3 which is moving the list _ head _ remove function call two lines ealier.
The following code is a modification from section which is moving the listheadremove function call two lines ealier. What will go wrong?
bag::sizetype bag::eraseconst valuetype& target
Library facilities used: cstdlib, nodeh
sizetype answer ;
node targetptr;
targetptr listsearchheadptr target;
while targetptr NULL
Each time that targetptr is not NULL, we have another occurrence of target.
We remove this target using the same technique that was used in eraseone.
targetptrsetdata headptrdata;
listheadremoveheadptr;
targetptr targetptrlink;
targetptr listsearchtargetptr target;
manynodes;
answer;
return answer;
Group of answer choices
The problem occurs when the target is the second item on the linked list. In this case, the target pointer is at the head of the list, so it would be a mistake to remove the head node before moving the target pointer forward
The problem occurs when the target is the first item on the linked list. In this case, the target pointer is at the head of the list, so it would be a mistake to remove the tail node before moving the tail pointer backward.
The problem occurs when the target is the first item on the linked list. In this case, the target pointer is at the head of the list, so it would be a mistake to remove the tail node before moving the tail pointer backward.
The problem occurs when the target is the last item on the linked list. In this case, the target pointer is at the tail of the list, so it would be a mistake to remove the tail node before moving the tail pointer backward.
The problem occurs when the target is the first item on the linked list. In this case, the target pointer is at the head of the list, so it would be a mistake to remove the head node before moving the target pointer forward.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
