in reply to Re: Generating 0 .. N Randomly and Efficiently
in thread Generating 0 .. N Randomly and Efficiently
Unless there's a bug in the implementation, the approach will finish. In fact, it's bounded by O(N2). Each iteration will find a new number - if the initial guess hit an already picked number, a scan for an unpicked number is made. And until all numbers have been picked, a scan will find an unpicked number.
Now, the approach won't be fair (due to clustering), and it won't be fast (quadratic vs. linear), and the implementation might contain bugs (and is huge for such a simple problem), the algorithm will finish (the implementation might not).
|
|---|