‎12-14-2011 12:18 AM
‎12-14-2011 08:42 AM
I am aware that I wrote "Very very large" array of enums, but in reality, most of the time the array size will be ~128. In such case scenario both methods would be fine to use.
I ran couple of benchmarks using an array of 128 enum values and the difference between both methods is not noticeable.
However, this enum mode.vi will be used in a sequence where other tasks are done before, and after this VI.
Therefore, if I want to avoid additional loading times if the array size were to be very very large, the brute force method would be my best bet.
Thanks a lot, Mark and Darin for your time.
‎12-14-2011 08:59 AM
@Darin.K wrote:
My crude estimates are that the lazy method I posted has O(10N) operations. 3 elements times 3 operations on N elements. The counting method has O(N) operations since there is one operation on all N elements. Sorting is O(Nlog2(N)) plus the 1D searching is O(N) because it does not take advantage of all the work you did sorting the array. For one million elements, log2(N) ~ 20 so there are roughly O(21N) operations. I guess the factor of ten is about right, and yes sorting is certainly the rate limiting step.
Nice analysis Darin. I guess the moral of the story is to consider all facets when deciding on what method to use. In the general case the brute force method is the better option. If you are guaranteed the data is already sorted then the search method would be a better option. This was an interesting thought experiment.
‎12-14-2011 11:41 AM