快速排序伪代码

quicksort(A,p,r)

{

if p < r;

   then q<- partition(A,p,r)

            quicksort(A,p,q-1)

            quicksort(A,p+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++;

                      exchange A[i]<->A[j]

exchange A[i+1]<->A[r]

return i+1

}

posted @ 2010-11-06 09:30  hailong  阅读(4365)  评论(0编辑  收藏  举报