Assume I have an array of doubles that looks like the following:
Array[10] = {10, 10, 10, 3, 10, 10, 6, 10, 10, 9, 10}
I need a function that can determine what the MAJORTY vote is in the array, in this case "10" because it is the number that appears the most often... And of course there is the situation when no majority exists (where they are equal), in that case I need to throw an exception...
Any clues? Aside from doing some really nasty looping on the array (for each index, determine how many exist with the same value, store a count in the array, and then scan the count array for the highest number and the value at that position is the winner, etc...)
See Question&Answers more detail:os