O(1)
o(1) constitutes a constant memory usage. So amount of input is inconsequential(不重要的).
O(n)
o(n) constitutes a linear memory usage. So more input means linearly more memory.
- O(n*n)
o(n*n) constitutes a quadratic memory usage. So more input means quadratically more memory (x^2 on average.
This measure of memory complexity in most cases is completely independent to the measure of time complexity. For computer algorithms it is important to know how the algorithm will manage both of these complexities to decide the quality of the algorithm. However both must be calculated separately. One may be more important than the other depending on your use cases and circumstances for the problem.
简单说O(n²)表示当n很大的时候,复杂度约等于Cn²,C是某个常数,简单说就是当n足够大的时候,n的线性增长,复杂度将沿平方增长。O(n)也是差不多的意思,也就是说n很大的时候复杂度约等于Cn,C是某个常数。O(1)就是说n很大的时候,复杂度基本就不增长了,基本就是个常量C。
还有一个:without using extra memory
指的是算法复杂度与输入的容量大小无关,是一个常数,可以理解为O(1)复杂度
参考: