The worst-case running time of mergesort on an input of size n is given by:
T(n)=c⋅nlog2n For n=64:
T(64)=c⋅64log2(64)=c⋅64⋅6=384c=30 seconds ⟹c=38430=645 s The maximum time available is 6 minutes=360 seconds. We need to find n such that:
c⋅nlog2n=360 645nlog2n=360⟹nlog2n=5360×64=72×64=4608 Let us check the given options:
For n=512=29:
nlog2n=512×9=4608
Thus, n=512 solves the problem in exactly 6 minutes.
Hence, (B) is the correct option.