Question
Using C++, create a singly linked list having 5 nodes when instantiated. Create the following methods for your linked list: 1) InsertBeginning(): This function will
Using C++, create a singly linked list having 5 nodes when instantiated. Create the following methods for your linked list:
1) 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.
2) 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.
3) 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.
4) DeleteBeginning(): This function will delete the first node of the linked list.
5) DeleteEnd(): This function will delete the last node of the linked list.
6) Delete(): This function will take a user input specifying which node to delete.
7) 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.
Please include a SinglyLinkedList.hpp, SinglyLinkedList.cpp, and main.cpp.
Please display code from the compiler and the output. Thank you!
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