Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use C + + In this problem, you will develop a new function in our provided LinkedList class. Please observe the already existing structures found

Use C++In this problem, you will develop a new function in our provided LinkedList class. Please observe the already existing structures found in LinkedList.h.
Create a new function named getStats. This function should take in no parameters and return an int*.
This function should:
Allocate an array on the heap.
Calculate the minimum of all nodes, maximum of all nodes, and the mean of all nodes. These numbers should be stored as integers. If the mean is a decimal value, round it down to the lower integer.
Return the pointer to the first element in the return array. The return array should be structured as [min, max, mean].
If head is nullptr, then your return array should have all three elements set to zero.
Minimum (Min):
The minimum value in a dataset is the smallest value.
For example, in the set of values 3,5, and 7, the minimum value is 3.
Maximum (Max):
The maximum value in a dataset is the largest value.
For example, in the set of values 3,5, and 7, the maximum value is 7.
Mean (Average):
The mean, or average, is calculated by summing all the values in a dataset and then dividing by the number of values.
For example, if you have the values 3,5, and 7, the mean would be (3+5+7)/3=15/3=5.struct Node
{
int data;
Node* next;
};
class LinkedList{
// FREEZE CODE BEGIN
void addHead(int data){
Node* newNode = new Node;
newNode->data = data;
newNode->next = head;
head = newNode;
}
// FREEZE CODE END
private:
Node* head = nullptr;
};

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

Step: 3

blur-text-image

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

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

What research interests does the faculty member have?

Answered: 1 week ago