两个大Os相乘(嵌套)

发布于 2024-09-27 13:36:47 字数 82 浏览 0 评论 0原文

如果函数 A 调用运行时间为 O(n^2) 的 n^c 个函数 B,那么函数 A 的时间复杂度是多少?它只是多项式 (n^c) 以及 c 刚刚变大吗?

If a function A calls n^c functions B that runs in O(n^2) time, what is the time complexity of function A? Is it just polynomial (n^c) as well as c has just gotten bigger?

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

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

发布评论

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

评论(1

一抹苦笑 2024-10-04 13:36:47

如果一个函数A调用另一个函数B,则总复杂度是AB复杂度的乘积。因此,在这种情况下,总复杂度为 O(nc · n2 ) = O(nc + 2)。

一般产品规则

f1 ε O(g1) 和 f2 ε O(g< /em>2) ⟹ f1·f2 ∈ O(g1·g1)

f·O(g) ∈ O(f·g)

If a function A calls another function B, the total complexity is the product of the complexities of A and B. So in this case the total complexity is O(nc · n2) = O(nc + 2).

The general rules for products:

ƒ1 ∈ O(g1) and ƒ2 ∈ O(g2) ⟹ ƒ1·ƒ2 ∈ O(g1·g1)

ƒ·O(g) ∈ O(ƒ·g)

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