O 表示法,O(∞) = O(1)?

发布于 2024-10-31 19:17:33 字数 132 浏览 1 评论 0原文

这么一想;有人会说 O(∞) 实际上是 O(1) 吗?

  • 我的意思是它不取决于输入大小?
  • 所以在某种程度上它是恒定的,尽管它是无限的。

或者是唯一“正确”的表达方式 O(∞)?

So a quick thought; Could one argue that O(∞) is actually O(1)?

  • I mean it isn't depend on input size?
  • So in some way its, constant, even though it infinity.

Or is the only 'correct' way to express it O(∞)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

清秋悲枫 2024-11-07 19:17:34

你的论点不太正确。

大 O 表示法忽略常量倍数; O(1)O(42) 之间没有区别,或者 O(log(n))O( 3π log(n)) 。

标准约定是不使用任何常数倍数。

然而,O(∞) 意味着一种永远终止的“算法”,而不是O(1),它会在某个时刻终止。

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.

西瓜 2024-11-07 19:17:34

回答这个问题:

O 表示法,O(∞) = O(1)?

主要区别在于 O(1) 将在某个时刻结束,而 O(∞) 永远不会结束。

它们都不包含变量,但具有不同的含义:

O(1)(或 O(121) 或 O(无论什么,但不是无穷大):独立于函数参数,但以

< code>O(∞) :独立于函数参数,并且非结尾

正如另一个答案中指出的那样,无穷大实际上并不在大 O 表示法的范围内,但简单的“不”仍然存在当然,O(1) 和 O(∞) 并不相同。

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.

强辩 2024-11-07 19:17:34

Big-Oh 是衡量所需资源如何随着 N 增加而扩展的指标。 O(5 小时) 和 O(5 秒) 都是 O(1),因为随着 N 的增加不需要额外的资源。

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.

风吹雪碎 2024-11-07 19:17:33

无穷大不是数字,或者至少不是实数,因此表达式格式错误。表达这一点的正确方法是简单地声明程序不会终止。注意:程序,而不是算法,因为算法一定会终止。

(如果您愿意,您也许可以在超限数上定义大 O 表示法。不过,我不确定这是否有任何用处。)

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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文