Is the time complexity of the empty algorithm O(0)?

后端 未结 14 2288
暗喜
暗喜 2020-12-12 21:29

So given the following program:


Is the time complexity of this program O(0)? In other words, is 0 O(0)?

I thought answering this in a separate question

14条回答
  •  甜味超标
    2020-12-12 22:15

    I have a very simple argument for the empty algorithm being O(0): For any function f(x), f(x) is in O(f(x)). Simply let f(x)=0, and we have that 0 (the runtime of the empty algorithm) is in O(0).

    On a side note, I hate it when people write f(x) = O(g(x)), when it should be f(x) ∈ O(g(x)).

提交回复
热议问题