众所周知,Fisher–Yates shuffle给出了以下"现代算法"代码:
To shuffle an array a of n elements (indices 0..n-1):
for i from 0 to n − 1 do
j ← random integer with **i** ≤ j < n
exchange a[j] and a[i]
我的问题是:如果我在&#34;i≤j&lt; N'#34;到0,算法也会像上面的算法一样随机,如何证明?修改后的代码是:
To shuffle an array a of n elements (indices 0..n-1):
for i from 0 to n − 1 do
j ← random integer with **0** ≤ j < n
exchange a[j] and a[i]