mardi 5 mai 2015

Randomly iterate through sequence of numbers, 1 to n

I have a range of numbers I want to iterate through. You can assume the sequence begins with 1 and ends with n, where n > 1. However, I do not want to iterate through them sequentially. The goal is is iterate through all of them in a random fashion. In addition, n can be very large, in the trillions possibly, so I cannot store the range in memory. Is there a way to do this?

I'm aware that there is a way to do this with an array, already in memory. Can something similar be done when you cannot store the entire range at once?




Aucun commentaire:

Enregistrer un commentaire