QUICKSORT(A,p,r)
if(p<r)
then q=PARTITION(A,p,r)
QUICKSORT(A,p,q-1)
QUICKSORT(A,q+1,r)
PATRTITION(A,p,r)
xA[r]
ip-1
for jp 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
快速排序时间复杂度
最坏情况时间复杂度(
)
平均情况时间复杂度(nlgn)
网友评论