THINK FIRST·CODE LATER

← All labs

findMode: the most frequent value of a sorted array

Problem

Write public static int findMode(int[] array) returning the value that occurs most often in a sorted array. If several values tie, return the first. Test with {2,5,6,7,7,10,10,11,11,13,15,15,15,19,20,20}, whose mode is 15.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.