2

Is the following true: $$ f(n) \in O(g(n)) \text{ then } 2 ^ {f(n)} \in O(2^{g(n)})$$

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503

2 Answers2

5

An obvious counterexample is $f(n) = n$ and $g(n) = \frac{n}{2}$. We know that $f(n) \in O(g(n))$, but $2^{f(n)} = 2^n \not \in O(2^{g(n)}) = O(2^{\frac{n}{2}}) = O(\sqrt{2^n})$.

Steven
  • 29,419
  • 2
  • 28
  • 49
OmG
  • 3,572
  • 1
  • 14
  • 23
0

In general, you would ask: For a function h(n), if f(n) = O(g(n)), is h(f(n)) = O(h(g(n))?

We have f(n) < c * g(n) for some constant c, and for large n. The function h(n) must be such that within the range of f(n) and g(n), h(f(n)) must not grow so fast that a linear change in f(n) creates a non-linear change in h(f(n)).

gnasher729
  • 29,996
  • 34
  • 54