对数和幂的渐近复杂性

发布于 2024-12-11 10:39:06 字数 461 浏览 0 评论 0原文

因此,显然,log(n)O(n)。但是,(log(n))^2 又如何呢? sqrt(n)log(n) 又如何——什么限制什么?

有一系列这样的比较:

nᵃ   (vs.)   (log(n))ᵇ

我经常遇到这些比较,但我从来没有想出一个好的方法来解决它们。解决一般案例的策略提示?


[编辑:我不是在谈论计算这些函数值的计算复杂性。我说的是函数本身。例如,f(n) = ng(n) = log(n) 的上限,因为 f(n) ≤ cg(n)< /code> 对于 c = 1n₀ > 0。]

So, clearly, log(n) is O(n). But, what about (log(n))^2? What about sqrt(n) or log(n)—what bounds what?

There's a family of comparisons like this:

nᵃ   (vs.)   (log(n))ᵇ

I run into these comparisons a lot, and I've never come up with a good way to solve them. Hints for tactics for solving the general case?


[EDIT: I'm not talking about the computational complexity of calculating the values of these functions. I'm talking about the functions themselves. E.g., f(n) = n is an upper bound on g(n) = log(n) because f(n) ≤ c g(n) for c = 1 and n₀ > 0.]

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

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

发布评论

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

评论(3

埋葬我深情 2024-12-18 10:39:06

对于任何正常数 a、b,log(n)^a 始终为 O(n^b)。

你在寻找证据吗?所有此类问题都可以通过以下技巧简化为 log(n) 为 O(n):

log(n)^a = O(n^b) 相当于:
log(n) = O(n^{b/a}),因为 1/a 次幂是一个递增函数。
这相当于
log(m^{a/b}) = O(m),通过设置 m = n^{b/a}。
这相当于 log(m) = O(m),因为 log(m^{a/b}) = (a/b)*log(m)。

您可以通过归纳法证明 log(n) = O(n),重点关注 n 是 2 的幂的情况。

log(n)^a is always O(n^b), for any positive constants a, b.

Are you looking for a proof? All such problems can be reduced to seeing that log(n) is O(n), by the following trick:

log(n)^a = O(n^b) is equivalent to:
log(n) = O(n^{b/a}), since raising to the 1/a power is an increasing function.
This is equivalent to
log(m^{a/b}) = O(m), by setting m = n^{b/a}.
This is equivalent to log(m) = O(m), since log(m^{a/b}) = (a/b)*log(m).

You can prove that log(n) = O(n) by induction, focusing on the case where n is a power of 2.

硪扪都還晓 2024-12-18 10:39:06
log n -- O(log n)
sqrt n -- O(sqrt n)
n^2 -- O(n^2)
(log n)^2 -- O((log n)^2)

n^a(log(n))^b

您需要相同的底数或幂。因此,使用您的数学将 n^a 更改为 log(n)^(无论它得到什么来获得这个基数)(无论它得到什么来获得这个幂) )^b。没有一般情况

log n -- O(log n)
sqrt n -- O(sqrt n)
n^2 -- O(n^2)
(log n)^2 -- O((log n)^2)

n^a versus (log(n))^b

You need either bases or powers the same. So use your math to change n^a to log(n)^(whatever it gets to get this base) or (whatever it gets to get this power)^b. There is no general case

盛夏尉蓝 2024-12-18 10:39:06

我经常进行这些比较(...)
解决一般情况的策略提示?

正如您关于一般情况以及您对此类问题的关注很多。这是我的建议:

使用 限制 BigO 表示法的定义,一旦您知道:

f(n) = O(g(n)) iff limit (n approaches +inf) f(n)/g(n) exists and is not +inf

您可以使用 计算机代数系统,例如开源Maxima,这里位于有关限制的 Maxima 文档

有关更多详细信息和示例 - 查看此答案

I run into these comparisons a lot (...)
Hints for tactics for solving the general case?

As you as about general case and that you following a lot into such questions. Here is what I recommend :

Use limit definition of BigO notation, once you know:

f(n) = O(g(n)) iff limit (n approaches +inf) f(n)/g(n) exists and is not +inf

You can use Computer Algebra System, for example opensource Maxima, here is in Maxima documentation about limits .

For more detailed info and example - check out THIS answer

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