GATE CSE
First time here? Checkout the FAQ!
x
+2 votes
54 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.4k points)   | 54 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.1k 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 (10.7k points)   | 40 views
+1 vote
0 answers
2
+2 votes
1 answer
3
Top Users Jan 2017
  1. Debashish Deka

    9716 Points

  2. sudsho

    5560 Points

  3. Bikram

    5290 Points

  4. Habibkhan

    4910 Points

  5. Vijay Thakur

    4498 Points

  6. Arjun

    4418 Points

  7. saurabh rai

    4236 Points

  8. Sushant Gokhale

    4226 Points

  9. Kapil

    3848 Points

  10. santhoshdevulapally

    3808 Points

Monthly Topper: Rs. 500 gift card

19,449 questions
24,228 answers
53,954 comments
20,373 users