dimanche 5 avril 2015

What is Big-O runtime of the standard random number generator in python? (Worst-case)

Sample python2 code:



for i in range(N):
print str(random.randint(0, N))


Is it safe to assume that the random number generator runs in O(1), so that the above loop (which simply prints N random numbers in the range from 0 - N) is O(N) ?





Aucun commentaire:

Enregistrer un commentaire