I am trying to get started on writting some code on modal average. The "modal average" of a set of values is the most commonly occurring value in that set. For example, the modal average of {0, 0, 1, 1, 1, 2, 1000} is 1. The modal average of {"abc", "abc", "def", "g", "g", "g", "hijk", "hijk"} is "g".
So, I am trying to write a function template for finding the modal average of sequence of values of any type that supports the < operator. Assume that the sequence is in sorted order, so that all occurrences of the same value will be adjacent within the array. If the modal average is ambiguous (i.e., the sequence contains multiple values that each occur k times, and no values that occur more than k times), then I want it to select the smallest value from among the possible modal averages. Help is all I can say.
Thanks