什么是秩序的符号F(N)= O(G(N))?符号、秩序

2023-09-11 05:24:04 作者:溺于你心海

问题1:在什么情况下会 0(F(N))= O(KF(N))是最合适的形式的时间复杂度分析?

问2:从数学定义工作0 符号,如何证明 0(F(N) )= O(KF(N)),为正数 K

对于第一个问题,我认为这是一般情况下和时间复杂度最坏情况下的形式。我对吗?还有什么我应该写的是什么?

对于第二个问题,我认为我们需要在数学上定义的功能。那么,答案是这样,因为乘以一个常数只是对应的任意常数 K 0的定义的值调整

解决方案   

我的观点:这是第一个我觉得这   是平均情况和最坏情况表   时间复杂性。我对吗?什么   别人做的我写的是什么?

没有!大O符号无关平均情况或最坏的情况。它只有约一个函数的增长的顺序 - 特别是,如何迅速的函数增长相对于另一个。函数 F O(N)在平均情况下和为O(n ^ 2)在最坏的情况 - 这只是意味着功能表现的不同取决于它的输入,因此这两种情况必须单独核算

对于问题2,这是有目共睹的我从你需要开始与大澳的数学定义为完整的缘故问题的措辞,它是:

  

正式的定义:F(N)= O(G(N))   意味着有正的常数Ç   和k,使得0≤F(N)≤CG(n)的用于   所有的n≥ķ。对C和K必须将这些值   固定不变的函数f和必须的   不依赖n个。

(来源 HTTP://www.itl.nist。 GOV / div897 / SQG /爸爸/ HTML / bigOnotation.html )

所以,你需要从这个定义工作,并编写出一个数学证明 F(N)= O(K(N))。首先替换 O(G(N)) O(K * F(N))在上述定义;其余的应该是相当容易的。

Question 1: Under what circumstances would O(f(n)) = O(k f(n)) be the most appropriate form of time-complexity analysis?

开头字母是e,o,g或n的单词有哪些

Question 2: Working from mathematical definition of O notation, how to show that O(f(n)) = O(k f(n)), for positive constant k?

For the first Question I think it is average case and worst case form of time-complexity. Am I right? And what else should I write in that?

For the second Question, I think we need to define the function mathematically. So is the answer something like because the multiplication by a constant just corresponds to a readjustment of value of the arbitrary constant k in definition of O?

解决方案

My view: For the first one I think it is average case and worst case form of time-complexity. am i right? and what else do i write in that?

No! Big O notation has NOTHING to do with average case or worst case. It is only about the order of growth of a function - particularly, how quickly a function grows relative to another one. A function f can be O(n) in the average case and O(n^2) in the worst case - this just means the function behaves differently depending on its inputs, and so the two cases must be accounted for separately.

Regarding question 2, it is obvious to me from the wording of the question that you need to start with the mathematical definition of Big O. For completeness's sake, it is:

Formal Definition: f(n) = O(g(n)) means there are positive constants c and k, such that 0 ≤ f(n) ≤ cg(n) for all n ≥ k. The values of c and k must be fixed for the function f and must not depend on n.

(source http://www.itl.nist.gov/div897/sqg/dads/HTML/bigOnotation.html)

So, you need to work from this definition and write a mathematical proof showing that f(n) = O(k(n)). Start by substituting O(g(n)) with O(k*f(n)) in the definition above; the rest should be quite easy.