Question
Write a C++ program to create a linked list of nodes of integers. The list, at its time of construction, contains head and tail nodes.
Write a C++ program to create a linked list of nodes of integers. The list, at its time of construction, contains head and tail nodes. Each new node added to the list, at a random position between the head and tail, contains a pointer to the following node and the tail node. The list has the following methods, namely
Constructor that constructs a new list, creating head and tail nodes with the values 0 and 1, respectively
Destructor that destroys the list, with the exception of the head and tail nodes.
Function to add a new node to the list
Function to print the list, printing the integer of each node, with each node between the head and tail also printing the integer in the tail node using its pointer to the tail node
The main function is to contain the following sequence of operations, namely
Create a list L Add a node with the value 3 to L Print L
Add a node with the value -7 to L
Print L
Add a node with the value 12 to L
Print L
Add a node with the value 9 to L
Print L
Add a node with the value -5 to L
Print L
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