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

Statistical Analysis of an Array The contents of an int array will be provided t

ID: 3854629 • Letter: S

Question

Statistical Analysis of an Array The contents of an int array will be provided to you one Learning You can create and initialize an array with those contents by using an array initialization list, as follows: intmainArr[]={//copyinarraycontentshere};Everyelementofthisarrayisanintbetween0and3000, exceptforthelastelement, whichis-1.Since we did not provide a size declarator in the array declaration, nordoweknowhowmanyelementsareinthearrayuntilweprocessit, thatlast-1canbeusedasasentinelvalueforourarrayprocessing.Itisnotconsideredpartofthedatasetinthearrayandshouldnotbeincludedinthefollowingcalculations.WriteaCprogramthatscansthroughthearraycontents(everythingexceptthe-1)and determines the following statistics on it: 1) the number of elements 2) the average of the elements 3) the minimum and maximum values 4) the second to last minimum and second to last maximum values (if the min or max values are duplicated, use the duplicated value not then next unique value) Your program should analyze the array, determine the above statistics, and printout there results in the following format. Total number: 700Average: 2462.9Minelement: 15Min2element: 21Maxelement: 2984Max2element: 2976 The average should be printed as a floating point value with one decimal position. All numbers should be right justified as indicated."Min2"refersto the second-to-smallest minimum element, and "Max2" refers to the second-to-largest maximum element. Note that it is not necessary to create an output file for this project. Printing there results to the console will be sufficient Please take the array for Program#4 and determine how many duplicate values there are the array and what their index positions are. The output should look like: Value1899was foundanindices: 1, 9. Value 1059 was found at indices: 20, 224, 475. Value 1607 was found at indices: 25, 120. Value 2535 was found at indices: 415, 488. Total Duplicates found: XX All of the indices for a given value are listed on one line. Your program should not have more than one entry for the same number. Only numbers that have at least one duplicate should be reported. Note that the meaning of a duplicate is "two numbers at different index positions that have the same value." This means that if a number appears n times in the array, there are a total of same value." This means that if a number appears n times in the array, there are a total of (n/2) = n times (n - 1)/2 duplicates for that number. Thus, if a number appears twice in the array, that contributes 1 duplicate to the total duplicate count. If a number appears 3 times, that contributes 3 duplicates. And if a number appears 4 times, that contributes (4 times 3)./2 = 6 duplicates to count.

Explanation / Answer

/* function to find all the repeating elements*/ void printRepeating( int arr[], int n) {     /* First check all the values that are*/     /* present in an array then go to that*/     /* values as indexes and increment by*/     /* the size of array*     for (int i = 0; i < n; i++)     {         int index = arr[i] % n;         arr[index] += n;     }     /* Now check which value exists more*/     /* than once by dividing with the size*/     /* of array*/     for (int i = 0; i < n; i++)     {         if ((arr[i]/n) > 1)             cout << i << " ";     } } /* Driver's code*/ int main() {     int arr[] = {1, 6, 3, 1, 3, 6, 6};     int arr_size = sizeof(arr)/sizeof(arr[0]);     cout << "The repeating elements are: ";     printRepeating( arr, arr_size);     return 0; }
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