Counting-Sort

Counting-Sort(A,B,k)

let C[0..k] be a new array

for i = 0 to k

C[i] = 0

for j = 1 to A.length

C[A[j]] = C[A[j]] + 1

//C[i] now contains the number of elements equal to i

for i = 1 to k

C[i] = C[i] + C[i-1]

//C[i] now contains the number of elements less than or equal to i

for j = A.length downto 1

B[C[A[j]]] = A[j]

C[A[j]] = C[A[j]] - 1

------<Introduction To Algorithm>

上一篇:ansible的安装部署及简单应用


下一篇:攻城狮在路上(壹) Hibernate(十)--- 映射值类型集合