简体   繁体   English

渐近符号max(m,n)= O(m + n)

[英]Asymptotic Notation max(m,n)=O(m+n)

I have studied Introduction to Algorithms by CLRS in great details,but one thing is not clear yet. 我已经详细研究了CLRS的算法介绍,但是尚不清楚。

Why is max(m,n)=O(m,n)? 为什么max(m,n)= O(m,n)?

Please explain,it would be great help! 请解释,这将是极大的帮助!

max(m, n) = O(m+n) simply means that, asymptotically speaking, max(m, n) doesn't grow more quickly than m+n . max(m, n) = O(m+n)仅仅意味着,渐近而言, max(m, n)增长速度不会比m+n快。 Since max(m, n) < m + n for all m, n , this must be true. 由于对于所有m, n max(m, n) < m + n m, n ,这必须为真。 Note that max(m, n) is equal either to m or n , either of which is guaranteed to be less than m + n (as long as m and n are nonnegative, which can be assumed). 请注意, max(m, n)等于mn ,这两个值都保证小于m + n (只要mn为非负数,可以假设)。

Strictly speaking G(n) ∈ O(F(n)) means means that G(n) belongs to the infinite set of functions that are asymptotically bound under or equal to some C * F(n). 严格来说,G(n)∈O(F(n))意味着G(n)属于无穷大的函数集合,这些函数在某些C * F(n)下渐近地绑定。

Big Oh Cheat Sheet 大哦备忘单

  • Big Oh - Bound under or equal to 大哦-下限等于
  • Little Oh - Bound under and not equal to 小哦-受约束, 等于
  • Theta - Equal to, not under or over Theta-等于,不小于或大于
  • Little Omega - Bound over and not equal to 小欧米茄-结界且不等于
  • Big Omega - Bound over and or equal to 大欧米茄-界于或等于

Misconception 误解

Expressing that something = O(f(n)) is mathematically incorrect although even most professors make this mistake, it should be something ∈ O(f(n)) 虽然即使大多数教授都犯了这个错误,但表示某物= O(f(n))在数学上是不正确的,但它应该是∈O(f(n))。

So it is true that Max(M, N) ∈ O(M + N) because Max(M, N) is asymptotically bound under or equal to M + N. 因此Max(M,N)∈O(M + N)是正确的,因为Max(M,N)渐近地绑定 M + N 之下或等于 M + N.

So it is true that 1 ∈ O(log n) ∈ O(n) ∈ O(n^2) ∈ O(n^2) ∈ O(n!). 因此,确实有1∈O(log n)∈O(n)∈O(n ^ 2)∈O(n ^ 2)∈O(n!)。

This took me some time to get my head around but it's very easy once you do. 这花了我一些时间来解决问题,但是一旦完成,这非常容易。 It's critical to fully grasp this once you get into more advanced topics in algorithms and data structures. 一旦进入算法和数据结构的更高级主题,充分掌握这一点至关重要。

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

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