2.2.26 #
解答 #
差距还是比较明显的,由于 Merge 会调用多次,而用于启动递归的 Sort 方法只会调用一次。
代码 #
var auxInSort = new AuxInSortMergeSort();
var auxInMerge = new AuxInMergeMergeSort();
var data1 = SortCompare.GetRandomArrayInt(100000);
var data2 = new int[data1.Length];
data1.CopyTo(data2, 0);
Console.WriteLine("在Sort中创建aux[]\t" + SortCompare.Time(auxInSort, data1) + "ms");
Console.WriteLine("在Merge中创建aux[]\t" + SortCompare.Time(auxInMerge, data2) + "ms");