QUESTION This program will keep two lists one to print the t
QUESTION: This program will keep two lists, one to print the text in forward order, and one to print the text in reverse order. The forward one is using our empty add() function, so nothing gets put into it. You\'ll fix that, as well as modifiying insert() and erase(). The reverse on works by inserting always at the head of the list, like a Stack.Functions insert(), erase(), and add() must be modified so that if the last node of the list changes, List::last must change, as well. YOU JUST HAVE TO COMPLETE THE PROGRAM SO THAT IT PRINTS THE OUTPUT IN THE FORWARD ORDER.
HINT: AFTER the existing code runs, there\'s an easy way to know if you just changed the last node in the list; if you did, it\'s time to update the \"last\" pointer. And remember that \'add\'-ing the first item is a special case. We could make a Linked List behave a lot like a Queue if it were really efficient to add a node at the end of the list, that is, without having to chase links from the head to the tail. So we will add another pointer to our List class that will always point at the last item in the list. Read the existing code carefully and understand how it works. The \"add\" function is now empty. If you run the file you should get an output that starts out like this:
CURRENT OUTPUT:
CURRENT PROGRAM:
[kpatel20ecomet HW05 vim main. cpp g Wall error C main. Cpp o main. O g++ Wall -Werror c list .cpp o list o g++ main. o list. o o demo /demo list data. txt Forward Reversed dog lazy the Of back the jumped fox brown quick TheSolution
The line backList.insert(str,0) needs to be re-laced by backList.push_front(str);
push_front() menthod adds a element infront of a list.
For example, first element placed at first position of the list then when second element comes push_front() menthod moves the first element to second postion and places new element at first postion of the list.
This generates a reversed list.
