If an algorithm with input n can solve a problem in fn milli

If an algorithm with input n can solve a problem in f(n) milliseconds. What is the effect in the time if you try to solve a problem with input 2n? (That is, to express f(2n) by using f(n))

a) f(n)=100n

b) f(n)=n^2

c) f(n)=2n

d) f(n)=log n

Solution

f(n) = log n since the time increases exponentially with increase in no of elements

Hence we use log function to claculate time complexity

If an algorithm with input n can solve a problem in f(n) milliseconds. What is the effect in the time if you try to solve a problem with input 2n? (That is, to

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site