In: Computer Science
When given an input of size 1024, suppose the runtime is 256ms. For what input size would the program have runtime of 1ms?
1) since run time(t) is proportional to 2^n where n is the input size.
(where c is a constant)
when n=1024 , t=256ms
when run time t=1ms then the input size is
2) since time(t) is proportional to n where n is the input size.
(c is constant)
when n=30 t=36 ms
when n=10 then
3) Same method as above
when n=4, T=20ms
when n=10
4) Time complexity of merge sort =
So time(t) where c is constant
when n=1,000,000 t=4 seconds
4=k*1,000,000 * log (1,000,000)
k*log(1000^2)=4/1,000,000
2*k*log(1000)=4/1,000,000
k*log(1000)=2/(1000^2)
k*1000*log(1000)=2/1000 seconds=(2/1000)*1000 ms= 2ms
(if u want u can find the value of k and follow the long way, I noticed that 1000^2=1,000,000 so that can be used as a shortcut to solve it)
5)
(c is constant)
when n=500 , t=100
when n=2000
t=100*2=200ms