[p2p-hackers] permutation

Michael Parker mgp at ucla.edu
Tue Nov 9 17:58:26 UTC 2004


See http://c2.com/cgi/wiki?LinearShuffle

I thought it was interesting that the following code does NOT do fair
shuffling:

for (int i = 0; i < NUM_ELEMENTS; ++i) {
other_index = random() % NUM_ELEMENTS;
int temp = array[other_index];
array[other_index] = array[i];
array[i] = temp;
}

Not exactly intuitive.

- Michael

Lutianbo wrote:

> Hi all,
> Would you please tell me some papers about uniform random permutation
> of an array?
> Thank you!
> Regards.
> ---Lu
>
>------------------------------------------------------------------------
>
>_______________________________________________
>p2p-hackers mailing list
>p2p-hackers at zgp.org
>http://zgp.org/mailman/listinfo/p2p-hackers
>_______________________________________________
>Here is a web page listing P2P Conferences:
>http://www.neurogrid.net/twiki/bin/view/Main/PeerToPeerConferences
>  
>




More information about the P2p-hackers mailing list