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

后端 未结 14 2301
暗喜
暗喜 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:29

    There is no such thing as O(0). Even an oracle machine or a hypercomputer require the time for one operation, i.e. solve(the_goldbach_conjecture), ergo:

    All machines, theoretical or real, finite or infinite produce algorithms with a minimum time complexity of O(1).

    But then again, this code right here is O(0):

    // Hello world!
    

    :)

提交回复
热议问题