Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.)
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 (countStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started