Let's get some clarity. There are 5 common notations (Bachmann–Landau notations): ω (small omega) Ω (big omega) Θ (theta) Ο (big o) ο (small o)它们像数学比较运算符一样工作:They works like mathematical comparison operators: < (strictly less) <= (less or equals) = (equals) >= (greater or equals) > (strictly greater)严格地说,大o只是一个上限,因此您不能仅根据big-o表示法就说哪个函数增长更快.Strictly saying, big o is just an upper bound so you can't say which function grows faster based just on big-o notation.例如,快速排序的最坏情况复杂度= O(n 2 ),但也可以说快速排序的最坏情况复杂度= O(n 889 ).就像我们可以说x<基于x <899的知识. 2.For example, quick sort has worst case complexity = O(n2) but it's also right to say that quick sort has worst case complexity = O(n889).It's just like we can say x < 899 based on knowledge that x < 2.由于存在限制行为,因此可以忽略函数的常量和较少顺序的加数(它们由最高顺序的加数控制").例如,如果f(x) = 33*n³ + n² + n + 3544,则正确地说f(x) = O(n³)(此外,正确地说f(x) = Θ(n³)信息更正确(Θ被称为tight bound)Because of the limiting behavior you can ignore constants and less-ordered summands (they are "dominated" by the highest order summand) of your functions.For example, if f(x) = 33*n³ + n² + n + 3544, it's right to say that f(x) = O(n³) (Moreover, it's right to say f(x) = Θ(n³) which is much more informative (Θ is called a tight bound) 这篇关于我如何写大O标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-27 11:25