2 2 votes Which of the given options provides the increasing order of asymptotic complexity of functions $f1$, $f2$, $f3$ and $f4$? $f1(n) = 2^n \\ f2(n) = n^{(3/2)} \\ f3(n) = nlogn \\ f4(n) = n^{(logn)}$ How $n^{3/2}$ is greater than $n^{logn}$ Algorithms algorithms time-complexity + – shipra tressa 2.6k views answer comment Share Follow Print See all 2 Comments 2 2 Comments reply Anand. commented Jun 18, 2018 reply Follow flag is the answer $f_1 > f_4> f_2> f_3 ????$ 0 0 replyShare arungate commented Jun 18, 2018 reply Follow flag @shipra tressa $n^\frac{3}{2}$ is not greater than $n^{log n}$ I think. May I know what is the answer given for this? 0 0 replyShare Please log in or register to add a comment.
2 2 votes Increasing order of asymptotic complexity of these functions is $f3<f2<f4<f1$. ie; $nlogn < n^{3/2} < n^{logn} < 2^n $. Let's see how: To check this, choose a value of $n$ which is positive and a fairly large one. A power of $2$ is preferred. I am taking $2^{16}$. $f3 \rightarrow nlog n \Rightarrow$ $2^{16} log (2^{16}) = 2^{16}$ x $2^4 = 2^{20}$ $f2 \rightarrow n^{3/2} \Rightarrow$ $ (2^{16})^{\frac{3}{2}} = 2^{24}$ $f4 \rightarrow n^{log n} \Rightarrow$ $ (2^{16})^{log({2^{16}})} = (2^{16})^{16} = 2^{256}$ $f1 \rightarrow 2^n \Rightarrow$ $2^{(2^{16})} = 2^{65536}$ arungate answered Jun 18, 2018 • edited Jun 18, 2018 by arungate arungate comment Share Follow See all 12 Comments 12 12 Comments reply Anand. commented Jun 18, 2018 reply Follow flag given answer is wrong. substituting the value and finding the answer may sometimes leads to negative marks in GATE. By the way your substitution calculation is also wrong. $f1=2^n=2^{2^{16}}=2^{65536}\neq 2^{32}$ 1 1 replyShare arungate commented Jun 18, 2018 reply Follow flag Oops , got messed up with that one. $2^n$ is biggest, and u r correct. I will edit it, may I know why this method is wrong then. 0 0 replyShare shipra tressa commented Jun 18, 2018 reply Follow flag Correct order is F1>F4>F2>F3 Can u explain how to compare F2 and F4 without substituting values? 1 1 replyShare arungate commented Jun 18, 2018 reply Follow flag That's what I got by substituting values. If there's any better method, would be helpful if someone can post, @Anand. @shipra tressa I'm a newbie, kind on me expected :-) 0 0 replyShare arungate commented Jun 19, 2018 reply Follow flag yes.. here it is... https://gateoverflow.in/2139/gate2011-37 0 0 replyShare ankitgupta.1729 commented Jun 23, 2018 reply Follow flag @arungate , nice explanation brother..but as Anand said substituting the large value may give wrong answer because at some large input f1 > f2 and it is possible that after that large input f2 > f1 ..if we find intersection point(s) of both functions then only we can say that after intersection point , which function is larger but it is not easy to find intersection point here...we can solve this problem using calculus easily... 1 1 replyShare arungate commented Jun 23, 2018 reply Follow flag @ankitgupta.1729 Yes true bro, I think some people may know how to use this method. If you can identify the functions given in choices then this gives quick answer for me. But as you said it may not work if the intersection points are hard to find. Matter of choosing $n > 100000$ when $100000n$ and $n^2$ are given. But not for all functions. :) 1 1 replyShare srestha commented Jun 23, 2018 reply Follow flag Also it is all about growth rate not about how in a certain point functions look like 0 0 replyShare ankitgupta.1729 commented Jun 23, 2018 i edited by ankitgupta.1729 Jun 23, 2018 reply Follow flag @arungate , bro, 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 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 that GATE2011 question... 3 3 replyShare arungate commented Jun 24, 2018 reply Follow flag Ok, thanks a lot for the explanation @ankitgupta.1729. 1 1 replyShare srestha commented Jun 25, 2018 reply Follow flag @ankit another point according to cormen "we cannot compare the functions $n$ and $n^{1+sinn}$ using asymptotic notation, since the value of the exponent in $n^{1+sinn}$ oscillates between $0$ and $2$, taking on all values in between.." Similar case happens for $n^{logn}$ too right? 0 0 replyShare ankitgupta.1729 commented Jun 26, 2018 reply Follow flag @srestha , no. In nlogn , both n and logn are strictly increasing increasing function, so overall nlogn is also increasing. we can check it by graph by putting values of n...but graph of sin n oscillates. sometimes increasing and sometimes decreasing. so we don't know the asymptotic nature when n tends to infinity. (or) if we apply the above definition of these non-negative functions, then $\lim_{n\rightarrow \infty } sinn$ does not exist . but $\lim_{n\rightarrow \infty } logn = \infty$ . Now we can't apply L'Hopital's rule because then $\lim_{n\rightarrow \infty } cosn$ does not exist. and no other trick will work because we don't know which particular value it is going to... ................................................................. In algorithms , n and f(n) are always non-negative and f(n) should be monotonically increasing function of running time because when input size increases then machine will take more time to process it. so it can't be decreases. 0 0 replyShare Please log in or register to add a comment.