TRICTLY USE TEMPLATE PROVIDE AT END OF QUESTION IN YOUR SOLUTION ---------------------------------------- Write a C++ program to implement insertion, deletion, and display operations in a Linked List Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. The class Node has the following member variable Datatype Variable Usage int data to store data Node* next to store the next node Define the following public member functions in the class LinkedList. Member function Function description void insertNode(int value) This function inserts the data into the linked list at the end void deleteNode(int value) This function deletes the node from the linked list void display() This function is used to display the nodes in the linked list In the main() function, read inputs and call the functions of the LinkedList class based on the inputs. Note: If the Linked list is empty while displaying, then print "List is empty" in the display() function. Input and Output Format: Refer to sample input and output for formatting specifications. [All text in bold corresponds to input and the rest corresponds to output.] Sample Input and Output 1: 1.Insertion 2.Deletion 3.Display 4.Exit Enter your choice : 1 Enter the element to be inserted : 10 Element 10 is inserted into the Linked list 1.Insertion 2.Deletion 3.Display 4.Exit Enter your choice : 1 Enter the element to be inserted : 3 Element 3 is inserted into the Linked list 1.Insertion 2.Deletion 3.Display 4.Exit Enter your choice : 1 Enter the element to be inserted : 2 Element 2 is inserted into the Linked list 1.Insertion 2.Deletion 3.Display 4.Exit Enter your choice : 3 10 3 2 1.Insertion 2.Deletion 3.Display 4.Exit Enter your choice : 2 Enter the element to be deleted : 3 Element 3 is deleted from Linked list 1.Insertion 2.Deletion 3.Display 4.Exit Enter your choice : 3 10 2 1.Insertion 2.Deletion 3.Display 4.Exit Enter your choice : 4 Sample Input and Output 2: 1.Insertion 2.Deletion 3.Display 4.Exit Enter your choice : 3 List is empty 1.Insertion 2.Deletion 3.Display 4.Exit Enter your choice : 4 ---------------------ONY USE BELOW TEMPLATE IN YOUR SOLUTION-------------------- MAIN.CPP #include #include "LinkedList.cpp" using namespace std; int main() { //fill your code here return 0; } LinkedList.cpp #include using namespace std; class LinkedList { private: Node* head = NULL; public: void insertNode(int value) { //fill your code here } void deleteNode(int value) { //fill your code here } void display() { //fill your code here } };
STRICTLY USE TEMPLATE PROVIDE AT END OF QUESTION IN YOUR SOLUTION
----------------------------------------
Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement.
The class Node has the following member variable
Datatype | Variable | Usage |
int | data | to store data |
Node* | next | to store the next node |
Define the following public member functions in the class LinkedList.
Member function | Function description |
void insertNode(int value) | This function inserts the data into the linked list at the end |
void deleteNode(int value) | This function deletes the node from the linked list |
void display() | This function is used to display the nodes in the linked list |
Note:
- If the Linked list is empty while displaying, then print "List is empty" in the display() function.
Input and Output Format:
Refer to sample input and output for formatting specifications.
[All text in bold corresponds to input and the rest corresponds to output.]
Sample Input and Output 1:
1.Insertion
2.Deletion
3.Display
4.Exit
Enter your choice :
1
Enter the element to be inserted :
10
Element 10 is inserted into the Linked list
1.Insertion
2.Deletion
3.Display
4.Exit
Enter your choice :
1
Enter the element to be inserted :
3
Element 3 is inserted into the Linked list
1.Insertion
2.Deletion
3.Display
4.Exit
Enter your choice :
1
Enter the element to be inserted :
2
Element 2 is inserted into the Linked list
1.Insertion
2.Deletion
3.Display
4.Exit
Enter your choice :
3
10 3 2
1.Insertion
2.Deletion
3.Display
4.Exit
Enter your choice :
2
Enter the element to be deleted :
3
Element 3 is deleted from Linked list
1.Insertion
2.Deletion
3.Display
4.Exit
Enter your choice :
3
10 2
2.Deletion
3.Display
4.Exit
Enter your choice :
4
Sample Input and Output 2:
1.Insertion
2.Deletion
3.Display
4.Exit
Enter your choice :
3
List is empty
1.Insertion
2.Deletion
3.Display
4.Exit
Enter your choice :
4
---------------------ONY USE BELOW TEMPLATE IN YOUR SOLUTION--------------------
MAIN.CPP
#include <iostream> #include "LinkedList.cpp" using namespace std; int main() { //fill your code here return 0; } |
LinkedList.cpp
#include <iostream> class LinkedList { }; |
NODE.CPP
#include <iostream> using namespace std; class Node { public: int data; Node* next; }; |
Step by step
Solved in 3 steps with 1 images