類似敘述題略
外排序用k路歸並(k>)是因為k越小歸並趟數越多讀寫外存次數越多時間效率越低故一般應大於最少的路歸並若將k路歸並的敗者樹思想單純用於內排序因其由勝者樹改進而來且輔助空間大完全可由堆排序取代故將其用於內排序效率並不高
R: R:
五算法設計題
void BubbleSort(int a[]int n) //相鄰兩趟向相反方向起泡的冒泡排序算法
{ change=;low=;high=n; //冒泡的上下界
while(low<high && change)
{ change=; //設不發生交換
for(i=low;i<high;i++) //從上向下起泡
if(a[i]>a[i+]){a[i]<>a[i+];change=;} //有交換修改標志change
high; //修改上界
for(i=high;i>low;i) //從下向上起泡
if(a[i]<a[i]){a[i]<>a[i];change=;}
low++; //修改下界
}//while
}//BubbleSort
[算法討論]題目中向上移理解為向序列的右端而向下移按向序列的左端來處理
[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
From:http://tw.wingwit.com/Article/program/sjjg/201311/23172.html