O-notation, O(∞) = O(1)?

喜你入骨 提交于 2019-12-01 02:56:59

Infinity is not a number, or at least not a real number, so the expression is malformed. The correct way to express this is to simply state that a program doesn't terminate. Note: program, not algorithm, as an algorithm is guaranteed to terminate.

(If you wanted, you might be able to define big-O notation on transfinite numbers. I'm not sure if that would be of any use, though.)

Your argument is not quite correct.

Big O notation disregards constant multiples; there's no difference between O(1) and O(42), or between O(log(n)) and O(3π log(n)) .

Standard convention is to not use any constant multiples.

However, O(∞) would mean an “algorithm” that never terminates, as opposed to O(1) which will terminate at some point.

To answer the question :

O-notation, O(∞) = O(1)?

No

The main difference is that O(1) will end at some point, while O(∞) never ends.

They both don't include a variable, but have both different meanings :

O(1) (or O(121) or O(whatever but not infinity) : independendent of the functions arguments, but ending

O(∞) : independendent of the functions arguments, and non ending

As pointed out in another answer, infinity isn't really in the domain of the big-O notation, but the simple 'no' than remains of course, O(1) and O(∞) are not the same.

Big-Oh is a measure of how something the resources required scales as N increases. O(5 hours) and O(5 seconds) are both O(1) since no extra resources are needed as N increases.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!