when we make randomize algorithm ,sometimes we randomize the input by permuting the given input array. Is it important to produce uniform random permutation? Because when i use the first code give better result than original code (Fisher-Yates Shuffle)
//mycode
n = A.length
for i = 1 to n
j = Random(i,n)
swap A[j] with A[j+1]
//Fisher-Yates Shuffle
n = A.length
for i = 1 to n
swap A[i] with A[Random(i,n)]
Aucun commentaire:
Enregistrer un commentaire