Big O 是否可能小于 O(1)?

发布于 2024-08-01 13:36:10 字数 204 浏览 4 评论 0原文

可能的重复:
有 O(1/n) 算法吗?

是否有可能你的代码是 Big O 小于 O(1) 吗?

Possible Duplicate:
are there any O(1/n) algorithms?

Is it ever possible for your code to be Big O less than O(1)?

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

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

发布评论

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

评论(3

萤火眠眠 2024-08-08 13:36:10

并不真地。 O(1) 是常数时间。 无论您将其表示为 O(1)O(2) 还是 O(.5) ,就纯粹的大而言,实际上没有什么区别O 表示法。

正如这个问题中所述,技术上可以有一个O(1/n),但现实世界中没有任何有用的算法可以满足这一点(尽管有些算法确实将 1/n 作为其算法复杂性的一部分)。

Not really. O(1) is constant time. Whether you express that as O(1) or O(2) or O(.5) really makes little difference as far as purely big O notation goes.

As noted in this question, it is technically possible to have an O(1/n), but that no real-world useful algorithm would satisfy this (though some do algorithm's do have 1/n as part of their algorithmic complexity).

画离情绘悲伤 2024-08-08 13:36:10

O(1) 简单地说就是常数时间操作。 该时间可以是 1 纳秒或 100 万年,该符号不是绝对时间的度量。 当然,除非您在时间机器的操作系统上工作,否则您的 DoTimeTravel( ) 函数可能具有 O(-1) 复杂度:-)

O(1) simply means a constant time operation. That time could be 1 nanosecond or 1 million years, the notation is not a measure of absolute time. Unless of course you are working on the OS for a time machine, than perhaps your DoTimeTravel( ) function would have O(-1) complexity :-)

少女七分熟 2024-08-08 13:36:10

唯一花费少于 O(1)(恒定时间)的事情是一个完全不执行任何操作的操作,因此花费的时间为零。 但即使是 NOP 通常也需要固定数量的周期......

The only thing that would take less than O(1) (constant time) would be an operation that did absolutely nothing, and thus took zero time. But even a NOP usually takes a fixed number of cycles...

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