edited by
18,018 views
46 votes
46 votes

Which of the given options provides the increasing order of asymptotic complexity of functions $f_1, f_2, f_3$ and $f_4$?

  • $f_1(n) = 2^n$
  • $f_2(n) = n^{3/2}$
  • $f_3(n) = n \log_2 n$
  • $f_4(n) = n^{\log_2 n}$
  1. $f_3,  f_2, f_4, f_1$ 
  2. $f_3, f_2, f_1, f_4$
  3. $f_2, f_3, f_1, f_4$
  4. $f_2, f_3, f_4, f_1$
edited by

5 Answers

Best answer
56 votes
56 votes
Answer is $(A)$.

$n \log_2 n < n^{3/2}$ is quite straightforward as $n^{{3}/{2}} = n \times n^{1/2}$ and $\log n < n^{1/2}$ as logarithmic growth is smaller than exponential growth however small be the exponentiation factor.

Also, $n^{3/2} < n^{\log_2 n} $ and $n^{3/2} < 2^n$.

Now only $n^{\log_2 n}$ and $ 2^n$ need to be compared.

Taking $\log$ of both $(\log_2 n)^2$  and $n$,

$n > (\log_2 n)^2$

Hence, $2^n >  n^{\log_2 n} $.

NOTE: We cannot compare two functions for asymptotic growth by taking $\log$ if they are giving constants after $\log$ operation.
edited by
19 votes
19 votes

1. $f_1(n) = 2^n$
2. $f_2(n) = n^{3/2} = n^1*n^{1/2} = n\sqrt{n}$
3. $f_3(n) = n \log_2 n$
4. $f_4(n) = n^{\log_2 n}$

$Remark:$
1. f1 is exponential function, which is largest among all.
2. f2 > f3
3. f4 > f3
4. f4 > f2

A is the correct answer!
 
 

12 votes
12 votes

There is a concept of Rates of Growth in Calculus.

Definition :-  f(x) <<<  g(x)  as x $\rightarrow$ $\infty$ means growth rate of f(x) is very  slow  as compared to g(x) when x $\rightarrow$ $\infty$  ie. $\frac{f(x)}{g(x)} \rightarrow 0 \, \, as \, \, x\rightarrow \infty$

It is true when f and g are non-negative.

So, we can say that :-

  1) $if \lim_{x\rightarrow \infty } \frac{f(x)}{g(x)} = \infty \, \, then\,\, f(x) >>> g(x)$ ie. growth rate of f(x) is higher than g(x)

                                                        (or)

  2)  $if \lim_{x\rightarrow \infty } \frac{f(x)}{g(x)} = 0 \, \, then \,\,g(x) >>> f(x)$ ie. growth rate of g(x) is higher than f(x)                            

Based on this fact we can say that :-

Rates of Growth of the following functions is :-

lnx << xp << ex << $e^{x^{2}}$ for p>0

and Rates of Decay should be :-

$\frac{1}{lnx}$ >> $\frac{1}{x^{p}}$ >> e-x >> $e^{-x^{2}}$ , p>0

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

Now , Rates of growth of Running Time of algorithms is same as order of growth of running time of  algorithms. It is already mentioned in Cormen

According to Cormen ,

f(n) is asymptotically larger than g(n) if f(n) = $\omega$ (g(n))

                                               (or)

$if \lim_{n\rightarrow \infty } \frac{f(n)}{g(n)} = \infty \, \, exist \, then\,\, f(n) \,\,becomes\,\, arbitrary \,\, large \,\, as\,\, compared\,\, to\,\, g(n) \,\,as\,\, n \,\,tends \,\,to\,\, infinity $

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

Now , In this Question ,

On comparing f2 and f3

$\lim_{n \rightarrow \infty } \frac{n^{\frac{3}{2}}}{nlogn} = \lim_{n \rightarrow \infty } \frac{n^{\frac{1}{2}}}{logn} , when \,n \neq \infty \,\,$$Now , using \,L'H\hat{o}pital \, Rule , \lim_{n \rightarrow \infty } \frac{n^{\frac{1}{2}}}{logn} = \infty$

I have taken natural log above because it does not matter and we can convert one base to another and then solve. It will give same answer

So, f2 >>> f3

Now , On comparing f1 and f4 :-

$\lim_{n \rightarrow \infty } \frac{2^{n}}{n^{logn}}$

Since , 2n = (eln2)n =  en*ln2

and nlnn = (eln n)ln n = $e^{(ln n)^{2}}$

Since , exponential is an increasing function. So, comparing 2n and nln n is same as comparing n*ln2 and (ln n)2

So, By using $L'H\hat{o}pital's \, Rule $

$\lim_{n\rightarrow \infty } \frac{n*ln2}{(ln n)^{2}} = \infty$

So, n*ln2 > (ln n)2

 and $\lim_{n \rightarrow \infty } \frac{2^{n}}{n^{logn}}$ = $\infty$

So, now we can say f1 >>>f4

Now, these 2 comparison of functions are enough to eliminate options in this question.

edited by
2 votes
2 votes

This can be solved easily by taking the large value for n, say, $n=2^{256}$.

$f_1(2^{256}) =2^n= 2^{2^{256}} = 1.15 * 10^{77}$

$f_2(2^{256})= n^{3/2} = (2^{256})^{(3/2)}=2^{384}$

$f_3(2^{256})= nlog_2n=2^{256}log_22^{256}=2^{256}*2^8=2^{264}$.

$f_4(2^{256})=n^{log_2n}=(2^{256})^{256}=2^{65536}$.

$\Rightarrow f_3,f_2,f_4,f_1$ in increasing order of asymptotic complexity.

Answer is (A).

Answer:

Related questions

18 votes
18 votes
2 answers
2
18 votes
18 votes
3 answers
4