快速排序 int partition(Sqlist &L int low int high){ lr[]=Lr[low]; pivotkey=Lr[low]key; while(low<high){ while(low<high&&Lr[high]key>=pivotkey) high; Lr[low]=Lr[high]; While(low<high&&Lr[low]key<=pivotkey) ++low; Lr[high]=Lr[low]; } lr[low]=lr[]; retrun low; }//Partition void Qsort(SQList &L int low int high){ //对顺序表L中的子序列Lr[lowhigh]作快速排序 if(low<high){ pivotloc=partition(Llowhigh); Qsort(Llowpivotloc); Qsort(Lpivotloc+high); } }//Qsort void QuickSort(Sqlist &l){//对顺序表L作快速排序 Qsort(LLkength); }//QuickSort 返回《数据结构》考研复习精编 [] [] [] [] [] [] |