[英]Proving if g(n) is o(f(n)), then f(n) + g(n) is Theta(f(n))
So I'm struggling with proving (or disproving) the above question. 因此,我正在努力证明(或证明)上述问题。 I feel like it is true, but I'm not sure how to show it.
我觉得这是真的,但是我不确定如何显示它。
Again, the question is if g(n) is o(f(n)), then f(n) + g(n) is Theta(f(n)) 同样,问题是如果g(n)为o(f(n)),则f(n)+ g(n)为Theta(f(n))
Note, that is a little-o , not a big-o!!! 注意,那是一个小o , 不是大o !!!
So far, I've managed to (easily) show that: 到目前为止,我已经成功地(轻松地)证明了:
g(n) = o(f(n)) -> g(n) < c*f(n) g(n)= o(f(n)) -> g(n)<c * f(n)
Then g(n) + f(n) < (c+1)*f(n) -> (g(n) + f(n)) = O (f(n)) 然后g(n)+ f(n)<(c + 1)* f(n) -> (g(n)+ f(n))= O (f(n))
However, for showing Big Omega, I'm not sure what to do there. 但是,对于显示Big Omega,我不确定该怎么做。
Am I going about this right? 我要这样做吗?
EDIT: Everyone provided great help, but I could only mark one. 编辑:每个人都提供了很大的帮助,但我只能标记一个。 THANK YOU.
谢谢。
One option would be to take the limit of (f(n) + g(n)) / f(n) as n tends toward infinity. 一种选择是取(f(n)+ g(n))/ f(n)的极限,因为n趋于无穷大。 If this converges to a finite, nonzero value, then f(n) + g(n) = Θ(f(n)).
如果这收敛到一个有限的非零值,则f(n)+ g(n)=Θ(f(n))。
Assuming that f(n) is nonzero for sufficiently large n, the above ratio, in the limit, is 假设对于足够大的n,f(n)不为零,则上述比率在极限范围内为
(f(n) + g(n)) / f(n)
(f(n)+ g(n))/ f(n)
= f(n) / f(n) + g(n) / f(n)
= f(n)/ f(n)+ g(n)/ f(n)
= 1 + g(n) / f(n).
= 1 + g(n)/ f(n)。
Therefore, taking the limit as n goes to infinity, the above expression converges to 1 because the ratio goes to zero (this is what it means for g(n) to be o(f(n)). 因此,当极限为n到无穷大时,由于该比率变为零(因此g(n)为o(f(n)),因此上述表达式收敛为1。
So far so good. 到现在为止还挺好。
For the next step, recall that in the best case, 0 <= g(n)
; 对于下一步,请记住最好的情况是
0 <= g(n)
; this should get you a lower bound on g(n) + f(n)
. 这应该给你
g(n) + f(n)
的下界。
Before we begin, lets first state what little-o and Big-Theta notations means: 在开始之前,让我们首先说明little-o和Big-Theta表示法的含义:
Little-o notation
小o表示法
Formally, that
g(n) = o(f(n))
(org(n) ∈ o(f(n))
) holds for sufficiently largen
means that for every positive constantε
there exists a constantN
such that形式上,
g(n) = o(f(n))
(或g(n) ∈ o(f(n))
)对于足够大的n
成立,意味着对于每个正常数ε
都有一个常数N
使得|g(n)| ≤ ε*|f(n)|, for all n > N (+)
From https://en.wikipedia.org/wiki/Big_O_notation#Little-o_notation . 来自https://en.wikipedia.org/wiki/Big_O_notation#Little-o_notation 。
Big-Θ notation
大Θ符号
h(n) = Θ(f(n))
means there exists positive constantsk_1
,k_2
andN
, such thatk_1 · |f(n)|
h(n) = Θ(f(n))
表示存在正常数k_1
,k_2
和N
,因此k_1 · |f(n)|
andk_2 · |f(n)|
和
k_2 · |f(n)|
is an upper bound and lower bound on on|h(n)|
是
|h(n)|
的上限和下限 , respectively, forn > N
, ie分别对于
n > N
,即k_1 · |f(n)| ≤ |h(n)| ≤ k_2 · |f(n)|, for all n > N (++)
From https://www.khanacademy.org/computing/computer-science/algorithms/asymptotic-notation/a/big-big-theta-notation . 来自https://www.khanacademy.org/computing/computer-science/algorithms/asymptotic-notation/a/big-big-theta-notation 。
Given: g(n) ∈ o(f(n))
给定:
g(n) ∈ o(f(n))
Hence, in our case, for every ε>0
we can find some constant N
such that (+)
, for our functions g(n)
and f(n)
. 因此,在我们的情况下,对于每个
ε>0
,对于函数g(n)
和f(n)
,我们可以找到一些常数N
使得(+)
f(n)
。 Hence, for n>N
, we have 因此,对于
n>N
,我们有
|g(n)| ≤ ε*|f(n)|, for some ε>0, for all n>N
Choose a constant ε < 1 (recall, the above holds for all ε > 0),
with accompanied constant N.
Then the following holds for all n>N
ε(|g(n)| + |f(n)|) ≤ 2|f(n)| ≤ 2(|g(n)| + |f(n)|) ≤ 4*|f(n)| (*)
Stripping away the left-most inequality in (*)
and dividing by 2, we have: 去除
(*)
最左边的不等式并除以2,我们得到:
|f(n)| ≤ |g(n)| + |f(n)| ≤ 2*|f(n)|, n>N (**)
We see that this is the very definition Big-Θ notation, as presented in (++)
, with constants k_1 = 1
, k_2 = 2
and h(n) = g(n)+f(n)
. 我们看到,这是定义非常清晰的Big-Θ符号,如
(++)
,常数k_1 = 1
, k_2 = 2
且h(n) = g(n)+f(n)
。 Hence 因此
(**) => g(n) + f(n) is in Θ(f(n))
Ans we have shown that g(n) ∈ o(f(n))
implies (g(n) + f(n)) ∈ Θ(f(n))
. Ans我们已经证明
g(n) ∈ o(f(n))
意味着(g(n) + f(n)) ∈ Θ(f(n))
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.