Say I have y distinct values and I want to select x of them at random. What\'s an efficient algorithm for doing this? I could just call rand(
If, for example, you have 2^64 distinct values, you can use a symmetric key algorithm (with a 64 bits block) to quickly reshuffle all combinations. (for example Blowfish).
for(i=0; i
This is not random in the pure sense but can be useful for your purpose. If you want to work with arbitrary # of distinct values following cryptographic techniques you can but it's more complex.