Question: this is an incorrect implementation that ignores the position desired and always inserts at the beginning of the list. As a result, note how the
this is an incorrect implementation that ignores the position desired and always inserts at the beginning of the list. As a result, note how the test result for the entry at position 4 fails! Your job is to fix this function so it inserts in the correct position in the list.
template
// This implementation ignores newPosition, and always put the new // item at the beginning of the list. // Your assignment is to correctly insert the item into newPosition newNodePtr->setNext(headPtr); headPtr = newNodePtr;
itemCount++; // Increase count of entries } // end if return ableToInsert; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
