我如何计算复杂度

发布于 2024-12-11 17:47:09 字数 84 浏览 0 评论 0原文

我发现我的算法总是执行 n!*4^n 步骤。我想知道它的复杂度是 O(n!*4^n) 还是其他?谢谢。

I have found out that my algorithm will always do n!*4^n steps . I'd like to know wheter its complexity will be O(n!*4^n) or will it be something else? Thanks.

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

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

发布评论

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

评论(3

与他有关 2024-12-18 17:47:09

如果您确定您的算法将始终执行n!⋅4ⁿ步,那么它的复杂度就是O(n!⋅4ⁿ),并且一个 θ(n!⋅4ⁿ) 以及一个 Ω(n!⋅4ⁿ)

If you are sure that your algorithm will do always n!⋅4ⁿ steps, it's a O(n!⋅4ⁿ) as well as it's a Θ(n!⋅4ⁿ) as well as it's a Ω(n!⋅4ⁿ).

榕城若虚 2024-12-18 17:47:09

它是 θ(n!⋅4ⁿ) 并且因为 θO 的下界,所以它也是 O(n!⋅4ⁿ)< /code> 也是 Ω(n!⋅4ⁿ)

重要的是你在你的步骤中做什么?如果每个步骤都是 O(1) 这个符号成立,但在其他情况下,这取决于你的步骤,我建议向我们展示你的函数,看看步骤是什么。

为什么你不能说它是O(n!)?因为你找不到常量c,这样:

n!⋅4ⁿ ≤ c⋅n!,对于 n > n0

因为对于任何常量 c,当 4ⁿ > c(例如当n ≥ c时)上述不等式是错误的。

It's Θ(n!⋅4ⁿ) and because Θ is lower bound for O it's also O(n!⋅4ⁿ) Also It's Ω(n!⋅4ⁿ).

Just important thing is what you doing in your steps? If each step is O(1) this notations hold, but in other cases, it's depend to your steps, I suggest show us your function, to see what's the steps.

And why you can't say it's O(n!)? because you can't find constant c such that:

n!⋅4ⁿ ≤ c⋅n!, for n > n0

because for any constant c when 4ⁿ > c (for example when n ≥ c) above inequality is wrong.

岁月打碎记忆 2024-12-18 17:47:09

如果它完全执行n!*4^n步,那么就没有必要使用大的oh符号。

是的,这意味着它的复杂度为 O(n!*4^n)。

If it does exactly n!*4^n steps, there's no real need for big oh notation.

And yes, that means it has O(n!*4^n) complexity.

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