Answered step by step
Verified Expert Solution
Link Copied!

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.)

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions