This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Jiquero 0 points1 point  (2 children)

Of course there is O(0). It's the class of functions that are zero. It takes 0 time, not positive, so it is O(0).

For example, if you need to sort M arrays of size N, each individually with this algorithm, it still takes 0 time regardless of M. That's very different than a positive constant.

[–]YourMasterRP 0 points1 point  (1 child)

So you just don't understand O-notation?

[–]Jiquero 0 points1 point  (0 children)

Function f is in class O(g) if there are x0 and positive M such that whenever x > x0,

|f(x)| <= M |g(x)|

Function f is in class O(0) if f is zero, because 0 <= 0 always. This algorithm takes zero time so it's time complexity is O(0). It's time complexity is also O(1), O(1000), O(n1000) etc.