ICE: Finding the array elements that occur the most frequently


Another example usage of Generate Sample Set instead of Repeat. This time, the problem is to find the array element with the most occurrences. This seems kinda long winded (it’s a three-step process), but it does handle the case where you have two or more elements that occur the same number of times.

FindMaxOccurrences

I used a temporary attribute for formatting purposes (so I didn’t have one big long horizontal tree). And I used a compound to encapsulate the bit that takes an array and converts it to a “per generated element” data set:
ArrayToPerElement

If you want, here’s a compound version.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s