I have an int array:
{1,2,4,2,3,5,6,4,3}
How can I find frequencies of array elements like 1=1,2=2,3=2,4=4..
. I need a class w
Without giving it away here is a good starting point:
int[] array = {1,2,4,2,3,5,6,4,3};
public int[] (array){
//need to perform a sort...or a search
//after searching check for matches,
//sorting could make performing comparisons more efficient
//not all searches/sorts are created equal.
int[array.length] result += {"["+numberChecked+"]="+freqOccurred};
return result;
}
This code is has not been compiled so think of it more as psuedocode. The purpose is to get you thinking about how to achieve the desired goal. An java package may already exist that can check the frequency elements in an array, but this is what you are most likely looking for. Good Luck.