I have a really simple method to traverse a known set of items randomly only once. It may or may not require a more memory than the method described in the book (depends on the size of the array) but it's definately faster (except of the initial creation).
The method is simple, you stick all of the elements you want into an array (for speed purposes, most likely an array of pointers). Next you loop through each element of the array and swap it's value with an other random element of the array. Voila! Everything will now be in some crazy mixed up order. Now, instead of doing some fancy calculations you can just grab each number/pointer sequentially from the array.
The method is simple, you stick all of the elements you want into an array (for speed purposes, most likely an array of pointers). Next you loop through each element of the array and swap it's value with an other random element of the array. Voila! Everything will now be in some crazy mixed up order. Now, instead of doing some fancy calculations you can just grab each number/pointer sequentially from the array.