Implement the insert function in SLList class to insert an item x at a particular position in the list indexed by i. For example, let L= [1,2,3]. A call toL.insert (4,1) will make L=[1,4,2,3]. You...


Implement the insert function in SLList class to insert an item x at a particular position in the list indexed by i. For example, let L= [1,2,3]. A call toL.insert (4,1) will make L=[1,4,2,3].<br>You should not change the item of existing nodes.<br>Below is a skeleton of the Node and SLList class:<br>template <typename ItemType> class Node<br>public:<br>ItemType item;<br>Node *next;<br>Node (ItemIype i, Node *n = nullptr) {<br>item - i;<br>next = n;<br>} ;<br>template <typename ItemType> class SLList {<br>private:<br>/** Pointer pointing to the sentinel node. */<br>Node<ItemType> *sentinel;<br>/** Stores the current size of the list. */<br>int count;<br>public:<br>// Other functions omitted...<br>void insert (const Item &x, int i) {<br>// Copy this function in the answer and write code below this line.<br>}<br>};<br>

Extracted text: Implement the insert function in SLList class to insert an item x at a particular position in the list indexed by i. For example, let L= [1,2,3]. A call toL.insert (4,1) will make L=[1,4,2,3]. You should not change the item of existing nodes. Below is a skeleton of the Node and SLList class: template class Node public: ItemType item; Node *next; Node (ItemIype i, Node *n = nullptr) { item - i; next = n; } ; template class SLList { private: /** Pointer pointing to the sentinel node. */ Node *sentinel; /** Stores the current size of the list. */ int count; public: // Other functions omitted... void insert (const Item &x, int i) { // Copy this function in the answer and write code below this line. } };

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here