What is the use case of RandomCover?
Ivan Kazmenko
gassa at mail.ru
Mon Feb 18 06:47:55 PST 2013
> 1. Speed.
> +randomShuffle performs O(n) steps and O(n) uniform() calls.
> -randomCover performs O(n^2) steps and O(n^2) uniform() calls.
>
> The latter however can (and perhaps should?) be optimized to
> O(n): in the implementation, the line
Sorry, this part doesn't look clear. O(n^2) total with O(n^2)
uniform() calls can be optimized to the same O(n^2) total but
with only O(n) uniform() calls. It can be further optimized to
O(n log n) total with O(n) uniform() calls using a Fenwick tree,
but will then require storing n ints instead of n bools.
More information about the Digitalmars-d-learn
mailing list