O(logn) + 是什么意思? O(n) 是什么意思?
刚刚有人告诉我,我的代码应该遵循 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“有人告诉我,我的代码应该遵循 O(logn) + O(n) 的复杂性准则”——在不知道代码应该做什么的情况下,没有人可以回答其合理的复杂性应该是多少。
请参阅大 O 表示法
"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
如果没有上下文,这个问题很难回答。 “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.