Results 1 to 1 of 1
Thread: Finding Mode of an array
- 02-13-2012, 10:51 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 1
- Rep Power
- 0
Finding Mode of an array
Trying to write a method that finds the mode (most frequent occurring integer) of a 10 int array. Having some trouble but this is what i have so far:
void findMostFrequent1(int list[])
{
int count = 0;
int value = -1;
int digits[] = new int[10];
for (int index=0;index<list.length;index++)
{
list[digits[index]]++;
}
for (int index=0;index<10;index++)
{
if (count > digits[index])
{
count = digits[index];
value = index;
}
}
System.out.println(value + " appears " + count + " times ");
}
Similar Threads
-
Code to calculate mode using array
By Nox_1031 in forum New To JavaReplies: 19Last Post: 09-06-2011, 05:48 PM -
Problem in Finding the Mode of Dice Roll Outcomes? Help?
By Kratos321 in forum New To JavaReplies: 3Last Post: 05-11-2011, 09:07 PM -
Problem in Finding the Mode of Dice Roll Outcomes? Help?
By Kratos321 in forum Advanced JavaReplies: 1Last Post: 05-11-2011, 03:21 AM -
Finding the Mode in An Array
By carlodelmundo in forum New To JavaReplies: 23Last Post: 10-31-2010, 12:44 PM -
[SOLVED] Array Mode Problem
By Banjo in forum New To JavaReplies: 6Last Post: 12-09-2008, 04:35 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks