English 中文(简体)
Prove or disprove n^2 - n + 2 ∈ O(n)
原标题:
  • 时间:2010-10-14 01:03:04
  •  标签:
  • big-o
  • proof

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?

最佳回答

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)
问题回答

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.

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.





相关问题
Prove or disprove n^2 - n + 2 ∈ O(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 ...

Complexity proof

I would to prove the following example: n^k = O (c^n) for every k and c>1 It is noticeable that the polynomial function grows faster than exponential function. We try to find k0 > 0 satisfying ...

Stable Matching Problem

I am currently reading an Algorithm s book and came across the Stable Matching Problem. And a question came to mind that I m curious about, but the book doesn t answer. In every SMP is it possible to ...

prove n = Big-O(1) using induction

I know that the relation n = Big-O(1) is false. But if we use induction involving Big-O it can be proved. But the fallacy is we cannot induct Big-O. But my question is how we can disprove the relation ...

Explain the proof by Vinay Deolalikar that P != NP [closed]

Recently there has been a paper floating around by Vinay Deolalikar at HP Labs which claims to have proved that P != NP. Could someone explain how this proof works for us less mathematically ...

Have I checked every consecutive subset of this list?

I m trying to solve problem 50 on Project Euler. Don t give me the answer or solve it for me, just try to answer this specific question. The goal is to find the longest sum of consecutive primes that ...

Formally verifying the correctness of an algorithm

First of all, is this only possible on algorithms which have no side effects? Secondly, where could I learn about this process, any good books, articles, etc?

Writing a proof for an algorithm [closed]

I am trying to compare 2 algorithms. I thought I may try and write a proof for them. (My math sucks, so hence the question.) Normally in our math lesson last year we would be given a question like <...

热门标签