Awesome q2a theme
+1 vote

In this question if we solve using logarithm we get time complexity of $g(n)>f(n)=h(n)$

But is taking $logarithm$ to find out the complexity always a safe way? I believe $NOT$. To support my claim I provide u with this link→ (Go through the comments of the selected ans)

Similarly, here we can also see that $n^{100}$ has larger complexity than $n!$ for values like 2,3,4….even 100. I do not know where the graph of f(n) and g(n) intersects and g(n) upper bounds f(n)

What is the best approach to solve then? as if I plug in large values computable by our $GATE$ calculator I get $n^{100}$ runtime higher than g(n) and on the other hand comparison with the help of log is an horrible idea in some case as $logf(n)=O(log$ $g(n))$ doesn't always means $f(n)=O(g(n)$ for example let $f(n)=n^2$ and $g(n)=n$ then $f(n)\neq O(g(n))$ but $logf(n)=O(log$ $g(n))$

So what is the approach to solve this problems to be $100\%$ sure about the ans?

ago in Operating System by (613 points)
edited ago by | 18 views
In general remember the increasing order of complexities:

constant divided by polynomial < constant < $logn$ < $(logn)^k$ < $n$ < $nlogn$ < $n(logn)^k$ < $n^k$ < $n^k(logn)^l$ < $n^{k+l}$ < $d^n$

Use this as a first level of analysis and eliminate some of the options.

When not to use logarithm method : if, after applying logarithm, you get some constant or a constant multiple/factor.

example: $n^2$ and $n^{100}$. If you apply logarithms, both are same complexity - though you know they are not.

If using 'sufficiently large numbers' - be judicious in choosing the large numbers. And don't stop with one trial. Perform the test with 2 sufficiently large numbers, and then take the ratio of the two trials for each function - to identify which grows the largest. I like to choose powers of 2, like $2^{1024}$,  $2^{256}$ - since they'll also work if you have $loglogn$.

Unfortunately there is no one-size-fits-all approach. You need to use everything you know about function growth and intuition to reach the solution.
So in this case as u can see we have $n^{100}$ and $n!$ how will you determine which is asymptotically larger?
$n!$ is exponential in $n$ ($n! \rightarrow n^n$ by Stirling's Approximation). Exponential is clearly larger than polynomial.

Thanks again.. :)

Please log in or register to answer this question.

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
Top Users Jan 2020
  1. shashin

    1163 Points

  2. Vimal Patel

    307 Points

  3. Deepakk Poonia (Dee)

    305 Points

  4. Debapaul

    237 Points

  5. Satbir

    192 Points

  6. SuvasishDutta

    137 Points

  7. Pratyush Priyam Kuan

    118 Points

  8. tp21

    108 Points

  9. DukeThunders

    96 Points

  10. pranay562

    95 Points

Monthly Top User and those within 60% of his/her points will get a share of monthly revenue of GO subject to a minimum payout of Rs. 500. Current monthly budget for Top Users is Rs. 75.
2,989 questions
1,509 answers
89,814 users