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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!