algorithm: a=[1,2,3.....n] for i in (1,n+1): j=rand(1,n+1): swap(a[i],a[j])
let us say that n=3: 132 213 231 these 3 are 5 times possible and 123 312 321 are 4 times possible....
similarly for n=4 2143 occurs maximum number of times = 15 times and 4231 and 4123 occurs min times i.e 8 times only....
i figured it out for n=1,2,3,4; but i am not able to figure out the permutation which is maximum possible and minimum possible.
rand(1,n+1)
needs to be changed torand(i,n+1)
. $\endgroup$ – Yuval Filmus Sep 12 '18 at 6:38