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
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