@zqbinggong
2018-03-06T21:37:27.000000Z
字数 510
阅读 1058
最大子数组
分治策略
算法导论
Permutate By Sorting(A)
n = A.length
let P[1...n]be a new array
for i to n
P[i] = Rnadom(1,n^3) #此时优先级各不相同的概率是 1-1/n
sort A,using P as sort keys
算法的运行时间是,并且该过程能够产生出一个均匀随机排列
Randomize In Place(A)
n = A.length
for i to n
Swap A[i] with A[Random(i,n)]