Merge sort takes 45 sec to sort an array of input size of 128. How much time would be needed to sort 512 items ?
Answers
Given: Merge sort takes 45 sec to sort an array of input size of 128.
To Find : How much time would be needed to sort 512 items
Solution:
Simple mathematics :
Time taken to sort 128 items = 45 secs
=> Time taken to sort 1 item = 45/128 secs
=> Time taken to sort 512 items = 512 x Time taken to sort 1 item
=> Time taken to sort 512 items = 512 x 45/128 secs
=> Time taken to sort 512 items = 4 x 45 secs
=> Time taken to sort 512 items = 180 secs
60 secs = 1 min
=> Time taken to sort 512 items = 180/60 Mins
=> Time taken to sort 512 items = 3 Mins
k x n log₂n = time
=> k x 128 log₂128 = 45
=> k x 128 log₂2⁷ = 45
=> k x 128 x 7 = 45
time taken for 512 size
k x 512 log₂52 = t
=> k x 512 log₂2⁹ = t
=> k x 512 x 9 = t
=> k x 128 x 4 x 9 = t
=> k x 128 x 7 x 4 x 9 / 7 = t
k x 128 x 7 = 45
=> 45 x 4 x 9 / 7 = t
=> t = 231 sec
Learn more:
it takes 2 hours for 6 pipes to fill a tank.how much time will be ...
https://brainly.in/question/14768315