Question: In C++ create a Node struct containing a string (element_name) and an int (element_count) as well as a node pointer (Node* next). Create a LinkedList

In C++ create a Node struct containing a string (element_name) and an int (element_count) as well as a node pointer (Node* next). Create a LinkedList class with the following public functions:

Constructor (with no parameters) creates an empty list.

Deconstructor deletes the list.

isEmpty checks if the list is empty.

AddData Adds a new Node to the Linked List. The new Node should be added to the front of the list.

DeleteData deletes a Node from the Linked List that contains the data specified as input parameters (name, count).

toString returns a string containing the contents of the LinkedList from the first Node to the last Node. For example:

 [Cat, 6] -> [Dog, 18] -> [Fish, 12] 

The class should also contain the following private member variables:

Node* first a pointer to the beginning of the LinkedList

Node *last a pointer to the end of the LinkedList (this variable may be useful but is optional)

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!