in reply to find maximum occuring element in a array

If you're looking for the mode of a set and you've been handed the set (meaning you weren't involved in building it) then you're going to have to iterate over each element and count. There's a quantum algorithm to do this more quickly, but the tech isn't there yet.

Why can't the elements be "put as a dictionary to set counters against them"? That's going to be the solution that most people hear will drive you towards. If you can't directly $count{thing}++ then you're going to have to $count{stringify(thing)}++ and find the mode(s) afterward.

Replies are listed 'Best First'.
Re^2: find maximum occuring element in a array
by capriguy84 (Novice) on Sep 07, 2011 at 16:43 UTC
    Thanks. How can I inspect the count of each element while building the array? I am using 'push' to create the array by reading from a CSV. I guess I would then have to dynamically create a dictionary and then set counter against each.

      Do it while you're pushing. You can run several lines of code on each piece of data or add each piece to multiple data structures. You can do whatever you want in order to get where you're going.