O(logn) + 是什么意思? O(n) 是什么意思?

发布于 2024-11-28 12:28:48 字数 94 浏览 5 评论 0原文

刚刚有人告诉我,我的代码应该遵循 O(logn) + O(n) 的复杂性准则。当提示我进行澄清时,我得到了“代码的复杂性:)”无论如何,任何超出所提供内容的澄清都将不胜感激。

I was just told by someone that my code should follow the complexity guideline of O(logn) + O(n). When prompted for clarification, I was presented with, "the complexity of the code :)" In any event, any clarification over and above the provided would be appreciated.

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

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

发布评论

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

评论(2

纸伞微斜 2024-12-05 12:28:48
O(logn) + O(n) = O(n)

“有人告诉我,我的代码应该遵循 O(logn) + O(n) 的复杂性准则”——在不知道代码应该做什么的情况下,没有人可以回答其合理的复杂性应该是多少。

请参阅大 O 表示法

O(logn) + O(n) = O(n)

"I was just told by someone that my code should follow the complexity guideline of O(logn) + O(n)" - without knowing what your code is supposed to do, no one can answer what its reasonable complexity should be.

See Big O notation

输什么也不输骨气 2024-12-05 12:28:48

如果没有上下文,这个问题很难回答。 “O(logn) + O(n)”本身没有什么意义,因为任何给定算法的渐近复杂度都将由线性项主导,因此编写“+ O(logn)”并不能澄清任何事情。

Without context, this is rather difficult to answer. "O(logn) + O(n)" by itself makes little sense because the asymptotic complexity of any given algorithm would be dominated by the linear term, so writing "+ O(logn)" doesn't clarify anything.

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