4

Which Big O class would the function (1/2)^n fall into?

On a purely mathematical basis, it seems like we would have to put it into O(1) because 1/2^n approaches 0 for any sufficiently large n.

However, when it comes to asymptotic analysis and Big O, we tend to do a lot of hand-waving and also refer back to formulas. 1/2 is technically a constant, so seemingly would fall into O(c^n).

I lean toward O(c^n) because saying "half an operation" makes no sense when talking about algorithms. What algorithm takes half the time as the input grows larger? At best, I see the math formula (1/2)^n referring to half of some time constant - say, a minute. So (30 seconds)^n becomes a huge number and the function clearly belongs in O(c^n).

A little help?

zzu
  • 258
  • 1
  • 11
  • Decreasing functions aren't much use in runtime/space cost analysis, but you see them all the time in amount-of-numerical-error analysis. There the difference between 1 and 1/n and 1/2^n is really important. Of course 1/n is trivially O(1) since Big-O is like <=. Maybe you intended to ask about Big-Theta instead? – Craig Gidney Oct 02 '16 at 21:43
  • I am trying to place a bunch of mathematical functions in order from least order of growth to highest. The function above is one of them. And I'm trying to figure out if it belongs under, say O(logn) or above, say, O(n^3). – zzu Oct 02 '16 at 21:49
  • So sure, Big Theta works... what Big Theta class is (1/2)^n in? – zzu Oct 02 '16 at 21:50
  • There aren't necessarily a fixed set of "big-O classes" that everything falls into and many functions are best described with themselves. Can you elaborate on your question? Where does this come from? Is this a problem set question? – templatetypedef Oct 02 '16 at 22:17
  • I am wondering if there is a coherent way to talk about this type of function in terms of asymptotic analysis. If not, Ok. You can't really talk about negative n in terms of algorithms (a negative sized dataset makes no sense), so maybe this is the same thing. I am wondering, given the common intersections between math and computer science, if someone has established a rule about how to handle this type of function. – zzu Oct 02 '16 at 22:27

2 Answers2

2

The function 0.5n is O(1), and also O(c) for any c > 0 (it is not O(0), since 0.5n > 0 for any n).

It is also o(1) (note little o).

It is not Θ(c) for any constant c. If c =0, the problem is that 0.5n > c for any n. For any c > 0, lim n → ∞ 0.5n < c.


Personally, I think that saying that it is Θ(0.5n) is the strongest and most accurate statement here.

Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73
Ami Tavory
  • 74,578
  • 11
  • 141
  • 185
0

You can't write an O(1/2^N) algorithm, because as N approaches infinity runtime would become infinitesimal, which isn't physically possible. You can't have less than one "operation".

Malcolm McLean
  • 6,258
  • 1
  • 17
  • 18
  • 4
    Big-O does not exclusively describe temporal behaviour. –  Oct 02 '16 at 22:01
  • I disagree. One of the primary uses of Big-O is describing "Time Complexity." I don't think this is uncommon in computer science when comparing algorithms? – zzu Oct 02 '16 at 22:11
  • @Malcolm McLean I am inclined to agree with you. It may be that this makes no sense in the context of algorithms. However, I thought I'd check to see if there was some kind of consensus already about this type of function. I know I've seen it elsewhere, but I've never seen it handled explicitly. – zzu Oct 02 '16 at 22:14