News for hackers. Stuff that matters.
Re:The Alias Method is an O(1) algorithm to select elements ... by pgsandstrom on Tuesday March 05, 2013 @05:09AM (#5323771)
"You could also use ranges, picking a random number between 0.0 and 1.0 and returning :win when the number is below 0.8, :lose otherwise. But, these algorithms are still O(n)"

Maybe my math is a bit rusty, but is this really O(n)? Why is that?

Re:The Alias Method is an O(1) algorithm to select elements ... by andreer on Tuesday March 05, 2013 @10:06AM (#5324807)
n here is the number of different elements you can choose from. If there was a third alternative, you'd have to add another if statement.