开发者

Multiplying (nesting) two big Os

If a function A calls n^c funct开发者_运维百科ions 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?


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜