retagged by
492 views
0 votes
0 votes

What is the right answer?

retagged by

1 Answer

0 votes
0 votes

Right answer is B

n= 10^6.                                                                                             (given)

-------------------------------------------------------------------------------------------------

insertion sort takes 10*n*n  units of time for n instructions.             (given)

=> insertion sort takes 10 * 10^6 * 10^6 units of time  for 10^6 instructions.

=> insertion sort takes 10^13 units of time  for 10^6 instructions.

=> insertion sort takes 10^7 units of time  for 1 instruction.

=> 1 instruction in 10^7 units of time..................................................(i)

-------------------------------------------------------------------------------------------------

merge sort takes 100*n*log n  units of time for n instructions            (given)

=> merge sort takes 100*10^6*log 10^6 units of time for 10^6 instructions.

=> merge sort takes 10^8* 19.931 units of time for 1 instruction.

=> 1 instruction in 10^8* 19.931 units of time ....................................(ii)

--------------------------------------------------------------------------------------------------

A executes 10^10 instructions in 1 second                                            (given)

=> 1 instruction in 1/10^10 second......................................................(iii)

-------------------------------------------------------------------------------------------------------

B executes 10^8 instructions in 1 second                                              (given)

=> 1 instruction in 1/10^8 second........................................................(iv)

------------------------------------------------------------------------------------------------------

computer A  runs insertion sort                                                           (given)

=> for 1 instruction resultant time will be   = 1/10^10  * 10^7          ( from (i) and (iii) )

                                                                    = 1000 second 

-------------------------------------------------------------------------------------------------------

computer B runs merge sort.

=> for 1 instruction resultant time will be   = 1/10^8 *10^8* 19.931 ( from (ii) and (iv) )

                                                                    = 19.931 second

                                                                    = 20 second                      (approx)

-------------------------------------------------------------------------------------------------------

speed of B/ speed of A

= time of A for 1 instruction / time of B for 1 instruction    ( since speed is inversely proportional to time)

= 1000 sec / 20  sec

= 50

Hence, B is 50 times faster than A

Related questions

0 votes
0 votes
2 answers
1
Arnabi asked Jan 28, 2017
624 views
1 votes
1 votes
1 answer
2
rahul sharma 5 asked Mar 9, 2018
1,314 views
Consider the modified merge sort where we divide array into 5 equal sub arrays instead if 2(as in standard merge sort).What is the time complexity if modified merge sort?...
1 votes
1 votes
1 answer
3