vendredi 21 août 2015

java: generate random permutation with the following tips

can anyone help me to generate random permutation using the following algorithm in java programming language, and show the result with no duplicated element

set p to identical permutation(1 to n)
for i = n down to 2 do {
    set j to be a random integer with 1<=j<=i
    swap p[j] and p[i]
end for




Aucun commentaire:

Enregistrer un commentaire