简单表达式的大O符号

Big O notation of simple expressiosn

为什么

2n^2 = O(n^3)

如定义所说

if f(n)<= cg(n), 
 n ,c > 0 
for all n > n0 

并且因为可以有很多上限 所以任何其他更好的上限

来自 Skiena 的定义:

f(n)=O(g(n)) means c·g(n) is an upper bound on f(n). Thus there exists some constant c such that always f(n) ≤ c·g(n), for large enough n (i.e. , n ≥ n0 for some constant n0).

这里f(n) = 2n^2, g(n) = n^3 让我们取常量 c = 2。所以 2n^2 <= 2n^3 对应 n >= 1。原来如此。

当然你可以用与O(n^2)相同的方式显示相同的c = 2

来自维基:

A description of a function in terms of big O notation usually only provides an upper bound on the growth rate of the function.

大 O 表示法仅提供上限,因此...

2n² = O(n²), 2n² = O(n³), ... , 2n² = O(whatever bigger than n²)