Question: Programming Project 1 4 . 1 2 . 3 : . Modify the linked list implementation to use a dummy node for the past -

Programming Project 14.12.3: .
Modify the linked list implementation to use a dummy node for the past-the-end position whose data member is unused. A past-the-end iterator should point to the dummy node. Remove the container pointer in the iterator class. Reimplement the member functions so that they have the same effect as before.
PLease use C++
#include
#include
#include
using namespace std;
class Node{
public:
string data;
Node *next;
};
void insert(Node **root, string val){
Node* newNode = new Node();
newNode->data = val;
if(root == NULL){
// insert at beginning of list
newNode->next = NULL;
*root = newNode;
}else{
newNode->next =*root;
*root= newNode;
}
}
void remove(Node** root, string val){
if(*root == NULL){
cout<<"List is empty."<data == val && curr != NULL){
// first node of linked list has to be deleted
*root=curr->next;
delete(curr);
cout<data != val){
prev = curr;
curr = curr->next;
}
if(curr == NULL)
{
cout<next = curr->next;
cout<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!