Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)

CSCI 1060U Programming Workshop I Laboratory #9 & #10 (2015)

Activity #2

Extend the LinkedList class by adding data analysis functionality.

The first step is to modify the AddData function to add a new Node alphabetically based on name (instead of only to the front of the LinkedList). This means that you will have to search through the lists contents and insert the new node in the appropriate location. This location could be at the beginning, middle, or end of the list.

The second step is to add the following friend functions: printRawData prints the data values and their counts. For example:

 Cat: 6 Dog: 18 Fish: 12 

printHistogram prints a histogram of the data. For example:

 Cat: ****** Dog: ****************** Fish: ************ 

calculateMean calculates the mean count for all data elements.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions