given a rand(N) a random generator 0 - N-1.
now
//assume N is defined somewhere
int A[N]
for(i = 0; i < N; i++){
int m = rand(N);
int n = rand(N);
swap(A[m],A[n]);
}
what is the probability that array A remains the same?
p.s. rand n swap are o(1) in case it makes any diff
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.