Question: Complete the C++ program below, by adding necessary member functions to the class List. When a main program such as if it runs, the output

Complete the C++ program below, by adding necessary member functions to the class List. When a main program such as if it runs, the output has to be similar to the sample output. In the main program you will work with a list of integers. The whole program should be written in one file ?StudentFullName.cpp? #include using namespace std; //-------------------------------------------------------------------------- //----------------------------- Header ---------------------------------- //-------------------------------------------------------------------------- template class Node { private: T data; Node *next; public: Node(T d, Node* n): data(d), next(n) {} T getData() const {return data;} Node* getNext() const {return next;} void setData(const T &d) {data = d;} void setNext(Node* n) {next = n;} }; template class List{ private: Node *head; public: List(); Node* getHead() const {return head;} void setHead(Node* h) {head = h;} boolisEmpty(); void insertFront(T newData); void deleteFront(); void printList(); int length(); void printBackwards(); void insertEnd(T newData); bool found(T target); void remove(T target); }; //-------------------------------------------------------------------------- //-------------------------- Implementation ------------------------------- //-------------------------------------------------------------------------- template List::List() : head(NULL) {}; template bool List::isEmpty(){ return (head==NULL); } template void List::insertFront(T newData){ Node* node= new Node(newData, head); head=node; } //-------------------------------------------------------------------------- //-------------------------- Client Program ------------------------------ - //-------------------------------------------------------------------------- int main() { //write your main program }

Sample output Operations on Linked lists 1- Insert an element in the front of the list......... 2- delete an element from the

Sample output: Operations on Linked lists... 1- Insert an element in the front of the list.... 2- delete an element from the front of the list.. element at the end of the list. 3- Insert an 4- Search an element in the list... 5- delete an element from the list..... 6- display all elements in the list... 7- display all elements in the list in reverse order. 8- display the length of the list.. 9- Exit the program... Choose an option from the menu: 1 Enter the integer to insert:1 Choose an option from the menu: 1 Enter the integer to insert:2 Choose an option from the menu:1 Enter the integer to insert:3 Choose an option from the menu: 6 List content: [3]--> [2]--> [1] --> Choose an option from the menu:3 Enter an integer to insert at the end:0 Choose an option from the menu: 6 List content: [3]--> [2] --> [1] --> [0] --> Choose an option from the menu: 7 List content backwards: [0]--> [1]--> [2]--> [3]--> Choose an option from the menu:8 length of list = 4 Choose an option from the menu:2 Choose an option from the menu: 6 List content: [2]--> [1]--> [0] --> Choose an option from the menu:5 Enter an integer to remove from the list:2 2 removed from list Choose an option from the menu:6 List content: [1]--> [0]--> Choose an option from the menu:1 Enter the integer to insert: 2 Choose an option from the menu:6 List content: [2] --> [1] --> [0] --> Choose an option from the menu:4 Enter an integer to search in the list:1 We found 1 Choose an option from the menu: 4 Enter an integer to search in the list:8 We did not find 8 Choose an option from the menu:9 End of the program

Step by Step Solution

3.42 Rating (161 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To complete the C program and achieve the desired output the missing member functions of the List class must be implemented Below is the complete program following the structure provided in the proble... View full answer

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 Programming Questions!