Could you please expand on your linked code, not really a C++ programmer and line 22/25 confuse me a bit?
Unfortunately I don't understand how each element has the same probability of being chosen.
I.e. the first element seems to have a probability of 1/n, while the second has 1/n + 1/(n-1) etc. Am i wrong about this?
Unfortunately I don't understand how each element has the same probability of being chosen. I.e. the first element seems to have a probability of 1/n, while the second has 1/n + 1/(n-1) etc. Am i wrong about this?