how do you find a mode in array?
This is what i got so far
i put this after i sort the array
1 2 3 4 5 6 7 8 9 10 11
for (int index = 0; index < size2; index ++)
{
//count[mode[index] - 1]++;
if (mode[index] == mode[index + 1]) // compare the first to sec array
{
again++;
cout <<"This is number " << again << endl;
}
}
Isn't the mode the number that appears the most in a set of given numbers?
Since it is sorted you could define a temp count variable that keeps track of the current number of times that number repeats , a last number variable to see if the current number is the same as the last if not see if the current count is greater than the last mode if it is assign it to the mode then reset the current count.