• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding mode

 
Kwesi Prat
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic