[英]How to Prove Asymptotic Notations
I want to prove the following statement 我想证明以下陈述
2^(⌊lg n⌋+⌈lg n⌉)∕n ∈ Θ(n)
I know that to prove it, we have to find the constants c1>0
, c2>0
, and n0>0
such that 我知道要证明这一点,我们必须找到常量c1>0
, c2>0
和n0>0
使得
c1.g(n) <= f(n) <= c2.g(n) for all n >= n0
In other words, we have to prove f(n) <= cg(n) and f(n) >= cg(n)
. 换句话说,我们必须证明f(n) <= cg(n) and f(n) >= cg(n)
。
The problem is how to prove the left hand side (2^(⌊lg n⌋+⌈lg n⌉)∕n)
问题是如何证明左手边(2^(⌊lg n⌋+⌈lg n⌉)∕n)
Thank you 谢谢
You can start by expanding the exponential. 您可以先扩展指数。 It is equal to n1*n2/n, where n1<=n<=n2, 2*n1>n and n*2>n2. 它等于n1 * n2 / n,其中n1 <= n <= n2、2 * n1> n和n * 2> n2。 The rest should be easy. 其余的应该很容易。
Here's a derivation for the upper bound: 这是上限的推导:
2^(⌊lg n⌋+⌈lg n⌉)/n
= 2^(2⌊lg n⌋+1)/n
<= 2^(2 lg n + 1)/n
= 2^(2 lg n) 2^(1) / n
= 2 n^2 / n
= 2 n
= O(n)
So we know your function can be bounded above by 2*n. 因此,我们知道您的函数可以被2 * n限制。 Now we do the lower bound: 现在我们执行下限:
2^(⌊lg n⌋+⌈lg n⌉)/n
= 2^(2⌈lg n⌉ - 1) / n
>= 2^(2 lg n - 1)/n
= 2^(2 lg n) 2^(-1) / n
= 1/2 n^2 / n
= 1/2 n
= O(n)
We now know that your function can be bounded below by n/2. 现在我们知道您的函数可以被n / 2限制。
Checked on gnuplot; 在gnuplot上检查; these answers look good and tight. 这些答案看起来又好又紧。 This is a purely algebraic solution using the definition if floor() and ceiling() functions. 这是使用floor()和ceiling()函数定义的纯代数解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.