3

Why or why not? It seems like the answer should be no, but on the other hand, it's weird that you'd reach the same value in a constant multiple of n.

J.-E. Pin
  • 40,163

3 Answers3

2

$2^{n}$ is $O(2^{n})$ but it is not $O(2^{n/2})$.

1

By exponent rules, $O(2^{n/2}) = O((2^{1/2})^n) \approx O(1.414^n)$ which clearly differs from $O(2^n)$ by more than a constant factor (consider the ratio).

qwr
  • 10,716
0

I made the same mistake once but if you write $x=2^n$, then you would have $O(x) = O(x^2)$ which of course doesn't make sense.

  • This answer doesn't work in general -- what if $x=2$? Then $O(x) = O(x^2) = O(e^x)$, which makes perfect sense (in this context, abusing notation in the way you do it by not viewing $x$ as a variable). – Carl-Fredrik Nyberg Brodda Oct 04 '22 at 17:47