"be consistent" | |
PerlMonks |
Re^2: assigning the maximum of two numbersby Tanktalus (Canon) |
on Nov 03, 2005 at 19:25 UTC ( [id://505484]=note: print w/replies, xml ) | Need Help?? |
Especially for large arrays? Wouldn't this be an O(nlogn) function? I mean, if you wanted an arbitrary number of the maximum numbers in a list, sure, you're pretty much already sorting. But for just the top 1, you should use an O(n) algorithm, which gets even more important for "large arrays". For short arrays, the difference between sort and looping with a ternary will be minor. For long arrays, well, it becomes a bit more important.
In Section
Meditations
|
|