Question: C++, THIS IS FOR AN UNSORTED ARRAY. I'm trying to implement an if statement that will check if there are 2 or more modes in

C++, THIS IS FOR AN UNSORTED ARRAY.

I'm trying to implement an "if" statement that will check if there are 2 or more modes in a data set. I tried checking "if (count == total)" then it would increment "pos" by 1 and put the other mode in the list (m[pos-1] = values[index]), but it kept giving me the same number multiple times. For instance, if the data set was {1,5,10,4,7,3,8,3,9,10} (the 3 and 10 occur twice) then i would get somewhere between 3 and 6 "10's" in the output for my mode. (std::sort and algorithm are off limits.)

C++, THIS IS FOR AN UNSORTED ARRAY. I'm trying to implement an

void calcMode (int valuesll, int listlength) int pos1: int mlposl/vill hold mode int count # 1. //starts count at 1 int total = 1: //holds highest number off occurences for (int index - 0: index total) total-count; n(pos-1] = values [index] ; if (count

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!