215 views
suppose merge sort takes 2 sec to sort a set of 64 keys then how much time will take to sort a set of 512 keys?

here, ans is 24 sec how it is plz explain me.

$T(n)= c\times n \log n$

$\Rightarrow 2 =c \times 64 \log _2 64=c \times 384\Rightarrow c=\frac{1}{192}$

$T(512)=c \times 512 \log_2 512=\frac{1}{192} \times 512 \times 9 =24$
thanks..

for merge sort time complexity =>

nlog2(n) = t

64 log(64) =2  ==>  26 * 6 = 2                             .... 1

than 512 log (512) ==> 29 * 9 = t                        .... 2

dividing 1 by 2.....

t = 23*3

which is equal to 24ans.

by

1 vote