can anyone explain what this part of the for loop is doing?
int findMode(int *array, int size)
{
int mode = -1, position = 0, highest;
int frequency[constant];
for(int i = 0; i < size; i++) //initailize all frequencies to 0
*(frequency + i) = 0;
for (int k = 0; k < size; k++)
{
for (int i = 1; i < size; i++)
{
if (*(array + k) == *(array + i) && &*(array + k) != &*(array + i)) //avoid counting itself in the scan
*(frequency + k) += 1; //increment the frequency of current number
}
}
highest = *(frequency + 0);
for (int count = 1; count < size; count++) // get position of highest number
{
if (*(frequency + count) > highest)
{
highest = *(frequency + count);
position =+ count; //get postion in frequency array, to put into numbers array
}
}
for(int i = 0; i < size; i++)
if(*(frequency + i) != *(frequency + (i + 1)) && (i + 1) < size)
{
mode = *(array + position);
return mode; //returns number that occurs most
}
return mode; //returns -1 if all same frequency