How do I determine a percentage increase of a function caused by increasing the input?

322 Views Asked by At

Suppose you have algorithms with the five running times listed below. (Assume these are the exact running times.) How much slower do each of these algorithms get when you (a) double the input size, or (b) increase the input size by one?

a) $n^2$ b) $n^3$ c) $100n^2$ d) $nlogn$ e) $2^n$

1

There are 1 best solutions below

0
On

It is (b) $\frac {f (n+1)-f (n)}{f (n)} $and (a) $\frac {f (2n)-f (n)}{f (n)} $. For example, for $n^2$, if you increase the input size by one, the percentage increase is

$$\frac{(n+1)^2-n^2}{n^2}=\frac{2n+1}{n^2}\times 100\%$$

If you double the input size, the percentage increase is

$$\frac{(2n)^2-n^2}{n^2}=300\%$$