Implement the algorithm described in Section 14.7.4, but only remember the value with the highest frequency so

Question:

Implement the algorithm described in Section 14.7.4, but only remember the value with the highest frequency so far:

int mostFrequent = 0;
int highestFrequency = -1;
for (int i = 0; i < a.length; i++)
Count how often a[i] occurs in a[i + 1] ... a[a.length - 1]
If it occurs more often than highestFrequency
highestFrequency = that count
mostFrequent = a[i]

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: