Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

template class DoublyLinkedList : public BaseDoublyLinkedList { public: I get(const unsigned int index) const; T& operator[](const unsigned int index) const; private: template T DoublyLinkedList::get(const unsigned int index) const { // some code here return T{}; // You don't want this, it just helps let it at least compile template T& DoublyLinkedList::operator[](const unsigned int index) const { // some code here I temp; return temp; // You don't want this, it just helps let it at least compile

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago