Analysis of an algorithm, many times we are more concerned about the time complexity of the algorithm run. In the time complexity of the algorithm, we are concerned about the time bounds of the algorithm running. That is, the large O-order analysis method.
Classification of time Complexity:
1, no cyclic recursion is basically a constant order.
2, there is a layer of circulation is the linear order.
for (int i=0;i<n;i++) {
Dosth
}
3, logarithmic order: generally similar to the following:
while (I<n) {
i=i*2;
}
Will cycle log2n times. So it's a logarithmic order.
4, Square Order
4.1 There are two for loops as follows:
for (int i=0;i<n;i++)
for (int j=0;j<n;j++) {
Perform an O (1) operation
}
4.2 There are two for loops as follows:
for (int i=0;i<m;i++)
for (int j=0;j<n;j++) {
Perform an O (1) operation
}
4.3 There are two for loops as follows:
for (int i=0;i<m;i++)
for (int j=0;j<i;j++) {
Perform an O (1) operation
}
The time complexity of an algorithm can be summed up in each key step. mainly the cycle.
Algorithm analysis of Time complexity