I'm working on a program to create an average of a set of arrays as well as the Median. I've pretty much gotten the average down, now it's on to incorporate the Median.
#include <iostream>
#include <algorithm>
using namespace std;
The median is defined as the value such that equal numbers of samples are less than it and greater than it. Therefore in a sorted array of samples, the median would be the mid-point of the array.
To find the median, you first have to sort the array. In this case, the array is already sorted, but you should check the assignment to see if you have to deal with other arrays that might not be sorted.
If the number of items is odd then the median is the "one in the middle." If the number of items is even then there is no "middle" item and the median is the average of the two closest to the middle. E.g., for the array { 12 18 19 24 35 50 }, the median is the average of 19 & 24.
If the length of array is even, we have two median:
1. length / 2
2. length / 2 + 1
If the length of array is odd, we have only one median:
1. (length + 1) / 2
In this case, the array is even, so we need to calculate two median.
Note that count + 1 is real length of the array tamalesConsumed in your code. The length of tamalesConsumed is even, so you will have two median.
dhayden, the assignment states that he would want it to be used as if he changed the array in the .cpp file. I guess if there was another array I believe there's a sort array that can be used as well.