我从很多来源读到了有关Big O符号的内容,包括Skiena和Wikipedia条目,Example部分说明:
在典型用法中,不使用O表示法的正式定义 直;相反,函数f(x)的O表示法由 遵循简化规则:
如果f(x)是几个项的总和,则保留增长率最大的项,省略所有项。
如果f(x)是多个因素的乘积,则任何
constants
(产品中不依赖于x的项)都是omitted
。
solution到problem 2.2是O((n ^ 3)/ 3)。不应该省略“/ 3”,或者我错过了什么?
答案 0 :(得分:4)
常量不需要省略,它们只是不携带任何信息 - O(n ^ 3)与O(n ^ 3/3)相同。您会注意到引用的段落讨论了典型用法,而不是严格的要求。
看一下具体的答案,解决方案渐近等于n ^ 3/3。虽然没有正式的任何不同于O(n ^ 3),我猜想这个想法是通过给出O来提供更具体的信息( n ^ 3/3)。
答案 1 :(得分:4)
不必须,O符号中允许使用正常数因子。它们只是毫无意义,因此应该省略。
答案 2 :(得分:3)
你是对的。 1/3是常数,因此应该省略。
答案 3 :(得分:2)
你是对的,为了正确,O(n ^ 3/3)(即O(1/3 * n ^ 3))应该从最终答案中省略1/3系数。这是因为表达式的1/3分量是微不足道的,具有极大的n。这将是编辑维基百科并进行修正的好机会。
答案 4 :(得分:0)
让我举个例子。
suppose we have function,
f(n)=1/3 * (4n^3) + 4n^2+ 1
lets gather all the facts...
we know that ,
for all sufficient large value of n>=1
1/3 * (4n^3) <= 1/3 * 4n^3
for all sufficient large value of n>=1
4n^2 <= 1/3 * 12n^3
and similarly, for all sufficent large value of n>=1
1 <= 1/3 * 5n^3
thus we can conclude that,
1/3 * (4n^3) + 4n^2+ 1 <= 1/3 * 4n^3 + 1/3 * 12n^3+1/3 * 5n^3 , where n >=1
lets simplify it,
1/3 * (4n^3) + 4n^2+ 1 <= (1/3) * 21n^3
f(n) <= (1/3) * 21n^3
f(n) <= ((1/3)*21)*n^3
f(n) <= (7)*n^3
f(n) = O(n^3) , where c=7 and n0=1
if we don't include 1/3 in c than,
f(n) <= (1/3) * 21n^3
f(n) <= (21)*(n^3 /3)
f(n) = O(n^3 /3), where c=21 and n0=1
so the constant value 'c' will be changed.