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?

in Operating System by (699 points)
edited by | 27 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
Top Users 2020 Aug 10 - 16
  1. Arkaprava

    404 Points

  2. jayeshasawa001

    198 Points

  3. SarathBaswa

    126 Points

  4. Ashutosh777

    67 Points

  5. toxicdesire

    20 Points

  6. Nilabja Sarkar

    12 Points

  7. premu

    10 Points

  8. iarnav

    7 Points

  9. Jhumpa_Sarma

    6 Points

  10. Patel0967

    6 Points

Weekly Top User (excluding moderators) will get free access to GATE Overflow Test Series for GATE 2021
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
Top Users Aug 2020
  1. Arkaprava

    404 Points

  2. jayeshasawa001

    203 Points

  3. Mellophi

    156 Points

  4. Ashutosh777

    143 Points

  5. SarathBaswa

    126 Points

  6. anurag sharma

    49 Points

  7. toxicdesire

    20 Points

  8. shashankrustagi2021

    16 Points

  9. premu

    16 Points

  10. Kushagra गुप्ता

    15 Points

7,769 questions
1,977 answers
95,111 users