2.2.24

2.2.24 #

解答 #

约为 $lgN$ 次

代码 #

var mergeSortX = new MergeSortX();
var n = 10000;
var trialTimes = 10;
Console.WriteLine("数组\t平均命中次数");
for (var i = 0; i < 4; i++)
{
    var avgHit = 0;
    for (var j = 0; j < trialTimes; j++)
    {
        mergeSortX.ResetHitTime();
        var a = SortCompare.GetRandomArrayInt(n);
        mergeSortX.Sort(a);
        avgHit += mergeSortX.GetHitTime();
    }

    Console.WriteLine(n + "\t" + avgHit / trialTimes);
    n *= 10;
}

另请参阅 #

Merge 库