Question
Using C++, Create a singly linked list having 5 nodes when instantiated. Create the following methods for your linked list: InsertBeginning(): This function will accept
Using C++, Create a singly linked list having 5 nodes when instantiated. Create the following methods for your linked list:
InsertBeginning(): This function will accept a value from the user, which will be used to create a new node at the beginning of the linked list.
InsertEnd(): This function will accept a value from the user, which will be used to create a new node at the end of the linked list.
Insert(): This function will accept a value and a location from the user, and will then add a node with the provided value in the location specified by the user.
DeleteBeginning(): This function will delete the first node of the linked list.
DeleteEnd(): This function will delete the last node of the linked list.
Delete(): This function will take a user input specifying which node to delete.
View(): This function will display the linked list.
This program should be menu driven, and once it is run, it will first display the initial linked list, and then ask the user for his/her option. The options will be the functions you are going to implement. The menu should be in a loop and will only end, if the user presses the option to terminate the program. After each operation is performed, the resulting linked list will be displayed to the user, before asking for his/her option again. Remember to consider every possible outcome of the program, and handle it accordingly.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started