3 ms·
Nice. Is that O(e^n)? Out of curiosity, why do you divide the rand() by 100 before applying the mod?
by demallien 13y ago
Nice. Is that O(e^n)?
Out of curiosity, why do you divide the rand() by 100 before applying the mod?
- ChuckMcM 13y agoNo reason on the divide. Just because. That is probably a reasonable guess on the big O value. Clearly O(rand) is cheeky but in accurate. And the PRNG will walk the number space so it will eventually succeed, but computing how long it will take for 'n' numbers eludes my math reasoning skills.
- emilv 13y ago> the PRNG will walk the number space Are you sure? What if there's an infinite amount of tries to get to a certain number? You can of course reason about the average case, but maybe the worst case (when there's an input number which is never found by the PRNG) does never halt. > O(rand) For sorting algorithms we usually compare in the number of input elements. You can reason about the average case where the numbers are found in average time so you can consider the number of iterations to find the correct number a constant (a very large constant but a constant nonetheless).