简体   繁体   English

简化大符号

[英]Simplify Big O notation

I apologize in advance for my poor math skills... 我对我的数学能力很差表示歉意。

I'm trying to understand how the math behind Big O Notation works. 我试图了解Big O符号背后的数学原理。 I understand from this that 2n^2 = O(n^3) and have proved that n = O(n^2) , but I also seem to have proved that n^3 = O(n^2) which doesn't make sense and I'm pretty sure is wrong. 从我明白2n^2 = O(n^3)和已经证明了n = O(n^2)但我也似乎已经证明, n^3 = O(n^2)其不有道理,我敢肯定这是错误的。 Here's how I'm "proving" this: 这是我“证明”的方式:

n^3 = O(n^2)
n^3 <= c*n^2
n <= c     #n^2 cancels out
1 <= c/n
c = 1; n0 = 1

What am I doing wrong? 我究竟做错了什么?

1 <= c/n does not hold for all n > n0 , for example, for n=2 (with your n0=1,c=1), you get: 1 <= c/n不适用于所有n > n0 ,例如,对于n = 2(n0 = 1,c = 1),您将得到:

1 <= 1/2

and this is a false statement. 这是一个错误的陈述。

The key in big O notation is you need to prove that for ALL n > n0 , the equation f(n) <= C*g(n) holds (for some C,n0 ) , in order to show f(n) is in O(g(n)) 大O表示法的关键是您需要证明对于所有n > n0 ,等式f(n) <= C*g(n)成立(对于某些C,n0 ),以表明f(n)为在O(g(n))

Normally Big O notation is defined as a set of functions with common asymptotic behaviour. 通常,Big O表示法定义为具有常见渐近行为的一组函数。 That is, as n grow large how will the function grow. 也就是说,随着n的增大,函数将如何增长。

In this case, we clearly see that n^3 outgrows n^2, so they are in fact in different O classes. 在这种情况下,我们清楚地看到n ^ 3超过n ^ 2,因此它们实际上在不同的O类中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM