문제

Is it possible to obtain a Big O estimate of Math.random()?

도움이 되었습니까?

해결책

I'm not sure this question makes much sense. There's no variable size input to increase gauge complexity against - you make a call (with no arguments) and you get an output.

Are you asking if the Math.random() method takes longer for successive calls? Or if it's just slower than it should be?

Remember that even algorithms with O(1) complexity can take a long time - it's just that the length of time they take doesn't depend on how much data is involved.

다른 팁

The algorithm is documented, see here. It's a Linear congruential generator which ends up having complexity of O(1)

it definitely is.. just look at how the function is implemented in the library and then apply recurrence-equations and do some math. ;)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top