The algorithm complexity is expressed by a Big O notation, like these

**O(1)**

**O(log**

*)*_{2}n**O(n)**

**O(nlog**

*)*_{2}n**O(**

*n*^{2})**O(**

*n*^{3})**...**

**O(**

*2*^{n}**)**

**...**

**The time complexity sequence is**

**Ο(1)＜Ο(log**

*)＜Ο(n)＜Ο(nlog*_{2}n*)＜Ο(*_{2}n*n*^{2})＜Ο(*n*^{3})＜…＜Ο(*2*^{n})＜Ο(n!)Basically, it describes the worst iteration times. For example, the code below

So the time complexity is O(2n

^{2}+ n + 1)

The big-O expressions do not have constants or low-order terms. This is because, when N gets large enough, constants and low-order terms don't matter.

- Remove constants, which is 1. Now it is O(2n
^{2}+ n) - Remove low-order terms, which is n. Now it is O(2n
^{2}) - Remove constant factor of high-order terms, which is 2 here. Then it is O(n
^{2})

The time complexity is

**O(**， because the inner iteration time is n*n.

*n*^{2})Here is the article http://blog.csdn.net/zolalad/article/details/11848739

Another article https://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/

## No comments:

## Post a Comment