GATE CSE
First time here? Checkout the FAQ!
x
+2 votes
56 views

Which of the following two is correct?

  • If f(n) = Ο(g(n)) then h(f(n)) = Ο(h(g(n)))
  • If f(n) ≠ Ο(g(n)) then g(n) = Ο(f(n))
asked in Algorithms by Boss (8.6k points)   | 56 views
second only.

1 Answer

+2 votes
Best answer
Both of them are incorrect.

For first one, let's assume $f(n) = n$ and $g(n) = n^2$. Clearly, $f(n) = O(g(n))$. Now consider $h(n) = 1/n$.

$h(f(n)) = 1/f(n) = 1/n$ and $h(g(n)) = 1/g(n) = 1/n^2$. Now for no constants $c$ and $n_0$, $0 \leq h(f(n)) \leq ch(g(n))$ for all $n > n_0$. (You can confirm this by plotting both $1/n$ and $1/n^2$).

So first statement is incorrect.

For second statement.

CLRS says "Not all functions are asymptotically comparable." That is, for two functions $f(n)$ and $g(n)$, it may be the case
that neither $f(n) = O(g(n))$ nor $f(n) = \Omega(g(n))$ holds. An example would be $f(n) = n$ and $g(n) = n^{1+\sin{n}}$

Hence, both of the statements are incorrect.
answered by Loyal (3.3k points)  
edited by

please explain Not all functions are asymptotically comparable. bit more.

That statement means that it is possible for two functions $f(n)$ and $g(n)$ to exist such that, you can't apply the definitions of any of $O$, or, $\Omega$, or, $\Theta$, or, $o$, or, $\omega$ between them.

Considering the same $f(n) = n$ and $g(n) = n ^ {1 + \sin{n}}$, Since $1 + \sin{n}$ oscillates between 0 and 2, $g(n)$ oscillates between $n^0$ and $n^2$, hence it's not possible to find two constants, $c$ and $n_0$ such that $0 \leq f(n) \leq cg(n)$ for all $n > n_0$ or similarly for other definitions.

You can get more insights from here

Related questions

0 votes
1 answer
1
asked in Algorithms by Akriti sood Veteran (12.3k points)   | 43 views
+1 vote
0 answers
2
+2 votes
1 answer
3


Top Users Mar 2017
  1. rude

    4008 Points

  2. sh!va

    2984 Points

  3. Rahul Jain25

    2804 Points

  4. Kapil

    2604 Points

  5. Debashish Deka

    2050 Points

  6. 2018

    1406 Points

  7. Vignesh Sekar

    1292 Points

  8. Bikram

    1204 Points

  9. Akriti sood

    1162 Points

  10. Sanjay Sharma

    964 Points

Monthly Topper: Rs. 500 gift card

21,435 questions
26,746 answers
60,901 comments
22,916 users