简体   繁体   English

O(n)+ o(nlogn)是什么?

[英]What would O(n) + o(nlogn) be?

What would o(nlogn) + O(n) be ? o(nlogn)+ O(n)是什么?

My guess is O(nlogn) ? 我的猜测是O(nlogn)吗?

f1(n) = o(nlogn) means for each constant c, there is an n0 such that 0 <= f1(n) < cnlogn . f1(n)= o(nlogn)意味着对于每个常数c,都有一个n0使得0 <= f1(n)<cnlogn。

And f2(n) = O(n) means there exists some constant c1, such that for n > n1, 0 <= f2(n) <= c1n . 并且f2(n)= O(n)意味着存在某个常数c1,因此对于n> n1,0 <= f2(n)<= c1n。

so , all I can get from this is that, there is some constant c1, such that for n > max(n0,n1), 0 <= f1(n) + f2(n) <= c1(nlogn) . 因此,我只能从中得到一个常数c1,对于n> max(n0,n1),0 <= f1(n)+ f2(n)<= c1(nlogn)。

If f is o(n log n) and g is O(n), then g is also o(n log n) so f+g is o(n log n) . 如果f是o(n log n)且g是O(n),则g也是o(n log n),因此f + g是o(n log n)

You do not get a positive lower bound. 您没有得到正的下限。 You do not get to say f+g can't be o(n) or even o(1). 您不必说f + g不能是o(n)甚至不能是o(1)。 The function 0 is both O(n) and o(n log n). 函数0既是O(n)又是o(n log n)。 So is sqrt(n). sqrt(n)也是如此。

Big-O and little-o notations are asymptotic upper bounds for the magnitude. 大O和小O表示法是幅度的渐近上限。 They are not lower bounds. 它们不是下界。 Big-Omega and little-omega are lower bounds. 大欧米茄和小欧米茄是下界。 Theta means you have both an upper bound and a lower bound of the same form. Theta表示您具有相同形式的上限和下限。 When you add together two upper bounds, you get an upper bound. 将两个上限加在一起时,您将获得一个上限。 You do not get a positive lower bound. 您没有得到正的下限。 In particular, you can't claim that the sum is not o(n). 特别是,您不能断言总和不是o(n)。

Lets look at asymptotical limits of those functions and their sum. 让我们看一下这些函数及其和的渐近极限。

First, upper limit: 一,上限:

F1 = o(n*log(n)), F2 = O(n) = o(n*log(n)), so
F1 + F2 = o (n* log(n))

Second, lower limit: we know F2 is O(N), but F1 can be zero for all we know, or anywhere between zero and n * log(n). 其次,下限:我们知道F2为O(N),但是就我们所知,F1可以为零,或者介于0和n * log(n)之间的任何值。 So all we can say for sure is that F1+F2 is not o(N). 因此,我们可以肯定地说的是F1 + F2不是o(N)。

I will let you put all that in terms of 'for each constant C there exists an index n' yourself. 我将用“对于每个常数C都存在一个索引n”来表示所有内容。

EDIT: Douglas pointed out that big-Oh and little-Oh are upper bounds only, and strictly speaking, you can't say anything about lower bounds at all. 编辑:道格拉斯指出,大哦和小哦只是上限,严格来说,您根本不能说下限。 This is absolutely correct. 这是绝对正确的。

However, in programming most of the time what we actually care about are worst-case scenarios, and nobody says that sqrt(n) = O(n) – which would technically be correct. 但是,在大多数时候,我们实际关心的是最坏的情况,并且没有人说sqrt(n)= O(n)–从技术上讲这是正确的。 So yes, we can talk about lower bounds, in a sense, if we mean worst-case. 所以是的,在某种意义上,如果我们指的是最坏的情况,我们可以讨论下限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM