快速排序:
QUICKSORT(A,p,r)
if p
then q←PARTITION(A,p,r)
QUICKSORT(A,p,q-1)
QUICKSORT(A,q+1,r)
PARTITION(A,p,r)
x←A[r]
i←p-1
for j←p to r-1
do if A[j] <= x
then i ← i+1
exchange A[i],,A[j]
exchange A[i+1],,A[r]
return i+1
计数排序
COUNTING-SORT(A,B,k)
for i ← 0 to k
do C[i] ← 0
for j ← 1 to length[A]
do C[A[j]] ← C[A[j]]+1
#C[i]包含等于ide元素个数
for i ← 1 to k
do C[i] ← C[i] + C[i-1]
#C【i】包含小于等于i的元素个数
for j ← length[A] downto 1
do B[C[A[j]]] ← A[j]
C[A[j]] ← C[A[j]] -1
#############################
最大值最小值
MINIMUM(A)
min ← A[1]
for i ← 2 to length [A]
do if min > A[i]
then min ← A[i]
return min
############################
http://blog.csdn.net/a81895898/article/details/7076823
阅读(579) | 评论(0) | 转发(0) |