Write an algorithm that reads a list of integers from the keyboard, creates a list of them using linked list implementation, and prints the result Solution /* Algorithm: Implementation of linked list. Create a node type class which will hold an integer and next pointer to point to another node. Create a constructor which will construct an object of type node with the integer type data as the only parameter and initializing next pointer to NULL. Create LinkedList class which will only have head pointer. Create a constructor which will initialize this head pointer to NULL. Create a append method which will recieve an input of type integer from the user and append it to LinkedList using below steps: 1.Create a Node type object. 1.IF head is NULL assign a Node type object created in 1st step. 2.IF head is not NULL then traverse to the end of the linked list till you found a Node which has next pointer set to NULL. 3.Add Node type object created in first step to the next pointer of last node. Create a print method which will traverse the list from the head of the linked list to the last node(Node with next pointer NULL) and while traversing it will keep printing the node data. Get the userinput: Ask user for integer continously till user input -1 and append all the integers to the linked list. */ PROGRAM: #include using namespace std; class Node { public: int data; Node *next; Node(int data) { this->data = data; this->next = NULL; } }; class LinkedList { private: Node *head; public: LinkedList() { head = NULL; } void addToFront(int data) { Node *temp = new Node(data); if(head == NULL) head = temp; else { temp->next = head; head = temp; } } void append(int data) { Node *temp = new Node(data); Node *current = head; if(current == NULL) { head = temp; return; } while(current->next != NULL) { current = current->next; } current->next = temp; } void print() { Node *current = head; if(current == NULL) cout << \"No element in list. \ \"; while(current != NULL) { cout << current->data << \" \"; current = current->next; } cout << endl; } void deleteLinkedList() { Node *prev; Node *current = head; while(current!=NULL) { prev = current; current = current->next; delete prev; } } void deleteLastNode() { Node *current = head; Node *prev = NULL; if(current == NULL) return; while(current->next != NULL) { prev = current; current = current->next; } if(prev == NULL) { delete current; head = NULL; } else { prev->next = NULL; delete current; } } ~LinkedList() { deleteLinkedList(); } }; int main() { LinkedList list; int data; while(1) { cout << \"Enter the integer(-1 to Quit) : \"; cin >> data; if(data==-1) break; list.append(data); } cout << \"Content of LinkedList is : \"; list.print(); return 0; } OUTPUT: Enter the integer(-1 to Quit) : 1 Enter the integer(-1 to Quit) : 2 Enter the integer(-1 to Quit) : 3 Enter the integer(-1 to Quit) : 4 Enter the integer(-1 to Quit) : -1 Content of LinkedList is : 1 2 3 4.