Working With Frequency Arrays...
So I have a hobby project I'm working on, where I have read in 100 000 random numbers between 1 and 50.
I have stored them in a frequency array of int's, (aptly named freq). So basically every time I read in
the number X, I would go freq[X]++; so therefore freq[X] is the number of times X occured.
I want to now pick out the 5 numbers that were generated the most frequently, and the 5 numbers that were generated
the least frequently.... Any ideas on how I would do this?
So basically I've created the following method:
public static void getMostCommonNumbers(int  freq)
int  mostFrequent;
/* INSERT CODE HERE */
System.out.print("\nThe numbers that appeared the most often were: ");
for(int k = 0; k < mostFrequent.length; k++)
System.out.print(mostFrequent[k] + " ");
Any help is much appreciated in this :).