证明或反驳 n^2 - n + 2 ∈在)

发布于 2024-09-27 20:42:27 字数 395 浏览 1 评论 0原文

在我的算法分析课程中,我从算法中导出了函数 f(n) = n^2 - n + 2。现在我需要证明或反证 f(n) ∈ O(n)。显然不是,所以我几个小时以来一直试图反驳这一点,但不知道该怎么做。

为了反驳它,我需要证明消极的一面:

∀M > 0, ∀N > 0, ∃n > N s.t. n^2 - n + 1 < M·n

我已经尝试过前后工作,但似乎无济于事。我还试图证明,与我的判断相反,f(n) ∈ O(n):

∃M > 0, ∃N > 0 s.t. ∀n > N, n^2 - n + 1 ≥ M·n

...但没有成功。我到底做错了什么?

For my algorithm analysis course, I've derived from an algorithm the function f(n) = n^2 - n + 2. Now I need to prove or disprove f(n) ∈ O(n). Obviously it's not, so I've been trying to disprove that for a few hours and can't figure out how to do it.

To disprove it, I need to prove the negative:

∀M > 0, ∀N > 0, ∃n > N s.t. n^2 - n + 1 < M·n

I've tried working backwards and forwards, but can't seem to get anywhere. I've also tried to prove that, against my judgment, f(n) ∈ O(n):

∃M > 0, ∃N > 0 s.t. ∀n > N, n^2 - n + 1 ≥ M·n

... with no success. What am I doing so horribly wrong?

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

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

发布评论

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

评论(3

回忆凄美了谁 2024-10-04 20:42:27

已经有一段时间了,但至少不是大θ......

f(n) ∈ O(g(n) <--> (∃c,m>0) | (∀n>m) 0 < f(n) <= cg(n)

let f(n) = n^2 - n + 2
let g(n) = n

(∃c,m>0) | (∀n>m) 0 < n^2 - n + 2 <= cn
(∃c,m>0) | (∀n>m) 0 < n^2 - n <= cn
(∃c,m>0) | (∀n>m) 0 < n^2 <= cn + n
(∃c,m>0) | (∀n>m) 0 < n^2 <= 2cn + n
(∃c,m>0) | (∀n>m) 0 < n^2 <= (2c+1)n

let C = 2c+1

(∃C,m>0) | (∀n>m) 0 < n^2 <= Cn
(∃C,m>0) | (∀n>m) 0 < n <= C

(∃C,m>0) | (∀n>m) 0 < n <= C

There is no constant C s.t. 0 < n <= C for all sufficiently large n.
Therefore, n^2 - n + 2 is not O(n)

It's been a while, but at least it's not big-theta...

f(n) ∈ O(g(n) <--> (∃c,m>0) | (∀n>m) 0 < f(n) <= cg(n)

let f(n) = n^2 - n + 2
let g(n) = n

(∃c,m>0) | (∀n>m) 0 < n^2 - n + 2 <= cn
(∃c,m>0) | (∀n>m) 0 < n^2 - n <= cn
(∃c,m>0) | (∀n>m) 0 < n^2 <= cn + n
(∃c,m>0) | (∀n>m) 0 < n^2 <= 2cn + n
(∃c,m>0) | (∀n>m) 0 < n^2 <= (2c+1)n

let C = 2c+1

(∃C,m>0) | (∀n>m) 0 < n^2 <= Cn
(∃C,m>0) | (∀n>m) 0 < n <= C

(∃C,m>0) | (∀n>m) 0 < n <= C

There is no constant C s.t. 0 < n <= C for all sufficiently large n.
Therefore, n^2 - n + 2 is not O(n)
剩一世无双 2024-10-04 20:42:27

假设有一些C> 0且M> 0 使得对于所有 n > 0 M,

n^2 - n + 1 <= Cn 对于所有 n > M

除以 n

n - 1 + 1/n <= C,对于所有 n > M

且因此

对于所有 n > n-1 <= C M.

这是不可能的。

Assume there is some C> 0 and M > 0 such that for all n > M,

n^2 - n + 1 <= Cn for all n > M

Divide by n

n - 1 + 1/n <= C for all n > M

and so

n-1 <= C for all n > M.

which is not possible.

记忆之渊 2024-10-04 20:42:27

反证法又如何呢?设置你的一般情况,以便你试图证明它是正确的,然后通过在每种情况下都必须是错误的陈述,那么整个证明必须是错误的。

What about a proof by contradiction. Set up your general cases such that you are trying to show it is true, and then by an statement which must be false in each case, then the whole proof must be false.

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