Time complexity 大O表示法复杂度顺序
我读过关于Big-O复杂性顺序的文章。在互联网上,它说订单是: O(1)Time complexity 大O表示法复杂度顺序,time-complexity,big-o,Time Complexity,Big O,我读过关于Big-O复杂性顺序的文章。在互联网上,它说订单是: O(1)
a: O(π^e n^2)
b: O(n+n^2/√n^3)
c: O((1/10^100)n!+5n^2)
d: O(25√9n)
e: O(log(n^n)
顺序e、d、a、b正确吗?我不确定c属于哪里。首先,请注意,从数学上讲,我从来没有听说过在O操作符的图像上有一个正确定义的顺序关系,所以当你说
O(1)
,据我所知,它没有数学定义,它只意味着复杂度为O(1)
的算法(对于大型问题)比复杂度为O(n)
的算法要慢
现在,为了回答您的问题,让我们简化所有表达式:
a: O(π^e n^2) <=> O(n^2) (a constant factor doesn't affect the nature of complexity itself although it will impact running time)
b: O(n+n^2/√n^3) <=> O(n^2/√n^3) (eliminating a term that evolves slower than the other term)
<=> O(√n) (simplifying expression)
c: O((1/10^100)n!+5n^2) <=> O(n!) (eliminating a term that evolves slower than the other term and removing constant factors)
d: O(25√9n) <=> O(n) (removing constant factors)
e: O(log(n^n)) <=> O(n log(n)) (simplifying expression)
a:O(π^en^2)O(n^2)(常数因子不会影响复杂性本身,尽管它会影响运行时间)
b:O(n+n^2)/√n^3)O(n^2/√n^3)(删除一个比另一个术语发展缓慢的术语)
O(√n) (简化表达)
c:O((1/10^100)n!+5n^2)O(n!)(去掉一个演化速度比另一个慢的项并去掉常数因子)
d:O(25√9n)O(n)(去除常数因子)
e:O(log(n^n))O(nlog(n))(简化表达式)
现在很明显,从快到慢的“顺序”将是:b,d,e,a,c
提示:谷歌“斯特林近似”