Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: assigning the maximum of two numbers

by Tanktalus (Canon)
on Nov 03, 2005 at 19:25 UTC ( [id://505484]=note: print w/replies, xml ) Need Help??


in reply to Re: assigning the maximum of two numbers
in thread assigning the maximum of two numbers

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.

  • Comment on Re^2: assigning the maximum of two numbers

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://505484]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-19 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found