in Algorithms retagged by
215 views
1 vote
1 vote
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.
in Algorithms retagged by
215 views

2 Comments

$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$
1
1
thanks..
0
0

1 Answer

2 votes
2 votes

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

Related questions