Question
Note that this is an incorrect implementation that ignores the position desired and always inserts at the beginning of the list. As a result, note
Note that 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. Once you've fixed it you should see the correct output from the tests.
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; } // end insert
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started