Question
T get (const unsigned intindex) const. This method accepts an integer. The method should then traverse to and return the kth node in the list.
T get (const unsigned intindex) const. This method accepts an integer. The method should then traverse to and return the kth node in the list. This is also zero based. It should throw int error (i.e. throw 1) if the index is invalid.T& operator[](const unsigned intindex) const. This is the overloaded [] operator. It is just a method, donot let the syntax scare you. Itis just a method that accepts an integer. This method is very similar to get. It should return the nodes value by reference (you dont have to do anything special for this, the T& returns it by referencefor you). It should throw int error (i.e. throw 1) if the index is invalid.voidinsert (const unsigned intindex, const T& value). This method accepts an integer and a value. The method will insert a new node at that index. Anything already at that index is automatically shifted up by one index. It can also insert at position 0 (before all nodes), and at a position just after the last node. This index is zero based, meaning it starts counting from zero. It cannot accept indexes past the end of the list. void remove(const unsigned intindex). This method accepts an integer. The method should then traverse to and delete the kth node in the list. This is zero based. Make sure you handle all scenarios (empty list, one node, first node, lastnode, and the general scenario.)void removeAllInstances(const T& value). This method accepts a value. The method should then remove all instances of that value. It cannot iterate down the list more than once, or in other words, it must traverse whileit deletes. It cannot loop which calls another method to loop and find a value to delete. (Some students have created their own privatemethod which accepts a reference to the node pointer, then updates that pointer to point to the next node in line. Note that the pointer must be passed in by reference, so that the caller can have the updated pointer as well.)
for this code
templateStep 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