当前位置:网站首页>Time complexity (see which sentence is executed the most times)

Time complexity (see which sentence is executed the most times)

2022-07-06 10:14:00 megaData

1.T (n) = O (f (n)) among f(n) Represents the sum of execution times per line of code ; and O Represents a positive proportional relationship

  • Constant order O(1)
  • Logarithmic order O(logN)
  • Linear order O(n)
  • Linear logarithmic order O(nlogN)
  • Square order O(n²)
  • Cubic order O(n³)
  • K Order of second order O(n^k)
  • Exponential order (2^n)
  • The time complexity from top to bottom is increasing , Less efficient execution .
  • Input range exceeds 10 Of 5 Power , Use both scanf no need cin

{
    if(T(n) Constant )
    {
         The time complexity is O(1);
    }
    else
    {
         The time complexity is O( Retain T(n) And remove the coefficient of the highest order );
    }
} Time complexity ( How many cycles are there , The time complexity is O(n To what power ));

IF Yes x Recirculation , The time complexity is O(n Of x Power );
The time complexity changes from fast to slow :O(1),O(logn),O(n),O(nlogn),O(n^2),O(n^3),O(2^n);

No matter how many lines of code are executed , As long as there is no complex structure such as circulation , So the time complexity of this code is very high O(1)

原网站

版权声明
本文为[megaData]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131720454784.html