Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please provide the code in C++ for the following problem. . Problem statement: I

ID: 656111 • Letter: P

Question

Please provide the code in C++ for the following problem.  .

Problem statement:

In statistics:

The mode of a set of values is the value that occurs most often or with the greatest frequency.

When a set of values is sorted in ascending or descending order, its median is the middle value. If the set contains an even number of values, the median is the mean, or average, of the two middle values.

Write a C++ application that do the following:

Define an array of size 10 and sore the values {1, 2, 3, 3, 3, 2, 2, 1, 3, 4, 5}. (Use array initializer.

Write a function that accepts as arguments the following:

A) An array of integers

B) An integer that indicates the number of elements in the array

The function should determine the mode of the array. That is, it should determine which value in the array occurs most often. The mode is the value the function should return. If the array has no mode (none of the values occur more than once), the function should return ?1. (Assume the array will always contain nonnegative values.)

Write a function to sort the array. (use selection sort algorithm)

Write a function that determine the median of the array. This value should be returned as a double.

Write a function to display the contents of the array

NOTE: for all the above functions, demonstrate your pointer prowess by using pointer notation instead of array notation.

Explanation / Answer

#include double GetMedian(double daArray[], int iSize) { // Allocate an array of the same size and sort it. double* dpSorted = new double[iSize]; for (int i = 0; i 0; --i) { for (int j = 0; j dpSorted[j+1]) { double dTemp = dpSorted[j]; dpSorted[j] = dpSorted[j+1]; dpSorted[j+1] = dTemp; } } } // Middle or average of middle values in the sorted array. double dMedian = 0.0; if ((iSize % 2) == 0) { dMedian = (dpSorted[iSize/2] + dpSorted[(iSize/2) - 1])/2.0; } else { dMedian = dpSorted[iSize/2]; } delete [] dpSorted; return dMedian; } double GetMode(double daArray[], int iSize) { // Allocate an int array of the same size to hold the // repetition count int* ipRepetition = new int[iSize]; for (int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote