嗨堆棧溢出用戶,選擇排序數組比較
我想了解如何計算一個方法內發生多少個數組比較。 arrayMaxPos函數使用n-1比較來查找大小爲n的數組中的最大元素。
我只是想找到我的頭。
public static void SelectSort(int [] a, int n)
{
for (int i = n; i> 1; i--)
{
int maxPos = arrayMaxPos(a, i);
swop(a, maxPos, i-1);
}
}
非常感謝。
由你檢查你的方式 - 沒有這種方法實際工程數組排序 - 烏爾從我運行一個循環= n到i> 1。 – exexzian 2012-07-29 23:14:38