A base portion: and Complex Analysis of Big O notation

   Learning data structures and algorithms complexity analysis from the start. Including the complexity of the algorithm time complexity and space complexity, both of which turned around the time complexity is relatively important, because in terms of Web applications, our common performance optimization strategy is space for time, such as caching system is.

   The time complexity of the execution time code indicating the change of data with the size increase, showing the method shown in FIG.

   

   That is the big O notation, we tend to follow the following principles in the analysis of time complexity:

     1, only concerned with the largest number of cycles to perform a piece of code;

     2, addition rule: the complexity of the overall complexity is equal to the order of the largest part of the code;

     3, the multiplication rule: the complexity of nested tags is equal to the product of the nested inner and outer code complexity.

   Thus, if the analysis of the time complexity of an algorithm is T (n-) = O (2N + 2) / T (n-) = (2N + 2N. 3 ^ + 2) O , the low-order equation, constant, based number three parts can be ignored, that is: T (n-) = O (n-) / T (n-) = O (^ n-2) .

     

   Time complexity in the segment up there the best, the worst, the average case time complexity of points:

     1, the best-case time complexity is in the best case execution time complexity of this code;

     2, the worst case time complexity is in the worst case, the execution time complexity of this code;

     3, where the average time complexity by definition is the binding of probability theory to analyze complex weighted average time from best to worst in each case on average

   In general, we are concerned about the complexity is enough , especially in the case only under stringent conditions, or the complexity of the same, we will further distinguish the best, worst, average complexity

   FIG get a "time complexity"

 

Guess you like

Origin www.cnblogs.com/mzhaox/p/11293993.html