Answered step by step
Verified Expert Solution
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 CIn 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 and the minimum value is
Maximum Max:
The maximum value in a dataset is the largest value.
For example, in the set of values and the maximum value is
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 and the mean would be struct Node
int data;
Node next;
;
class LinkedList
FREEZE CODE BEGIN
void addHeadint data
Node newNode new Node;
newNodedata data;
newNodenext head;
head newNode;
FREEZE CODE END
private:
Node head nullptr;
;
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