Big O notation(大 O 记号)是一种用来描述算法时间或空间复杂度增长趋势的记法,关注输入规模 (n) 变大时,运行时间/内存需求的上界(增长速度),常用于比较算法效率(如 (O(n))、(O(n\log n))、(O(n^2)))。在不同语境下也可泛指“复杂度量级”。
Big O notation helps us compare algorithms by how fast they grow as input size increases.
大 O 记号帮助我们按输入规模增大时的增长速度来比较不同算法。
Although the constants are ignored in Big O notation, choosing an (O(n\log n)) approach over an (O(n^2)) one can dramatically improve performance on large datasets.
尽管大 O 记号会忽略常数项,但在大数据集上选择 (O(n\log n)) 而不是 (O(n^2)) 的方法,性能差异可能非常显著。
/ˌbɪɡ oʊ noʊˈteɪʃən/
“大 O 记号”源自数学中的兰道记号(Landau symbols),用于描述函数在极限情况下的增长阶。符号 O 来自德语 Ordnung(“阶、数量级”)的首字母。该记法在 19 世纪末由 Paul Bachmann 等人系统使用,后在计算机科学中被广泛采用,用来表达算法复杂度。