about counting sort algorithm
问题 I have read a counting sort algorithm which is like this: Counting Sort(A[1,..n]) //C[1,...k] is the temporary memory and k is the range of integers for i<-- 1 to k C[i]<-- 0 for j<-- 1 to n C[A[j]]<--C[A[j]]+1 for i<--2 to k C[i]<--C[i]+C[i-1] for j<--n downto 1 B[C[A[j]]]<--A[j] C[A[j]]<--C[A[j]]-1 I want to know that if I change the last for to this: for j<--1 to n ,the algorithm will be correct too???(is there any way to show that with this "for" the algorithm will be correct??? ) also in