This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Customer Requirements for Developers and have Marcho Behler on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Finding mode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Finding mode" Watch "Finding mode" New topic
Author

Finding mode

Kwesi Prat
Greenhorn

Joined: Dec 02, 2003
Posts: 7
I am trying to figure out some coding on how to find mode for an array of integers? How do I go about the coding for mode?
Thank you.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24189
    
  34

Hi,
Welcome to JavaRanch!
If memory serves me right, the mode is the most common value, yes? Well, you loop over the array, and count the occurrences of each value.
Give it a try, come back and show us how far you get.


[Jess in Action][AskingGoodQuestions]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Finding mode
 
It's not a secret anymore!