Complexity of the algorithm includes time complexity and spatial complexity 1) time complexity
That is, the computational effort required to implement the algorithm. The workload of the algorithm is calculated using the number of basic operations performed by the algorithm to calculate the size of the same problem, and if the basic number of times the algorithm needs to execute depends on a particular input, the following two methods can be used to analyze the workload of the algorithm:
Algorithm workload =f (n)
(1) Average sexual state
Using a weighted average of the number of basic operations under a variety of specific inputs to measure the algorithm's work set X is a specific input in a possible input, p (x) is the probability that x appears, and T (x) is the number of basic operations performed by the algorithm when it is entered as X, the average state of the algorithm is defined as:
The DN represents the worst case complexity of all the possible inputs (2) when the algorithm executes when the scale is n
Refers to the maximum number of basic operations performed by the algorithm when the size is N. It is defined as:
2) spatial complexity of the algorithm
Refers to the amount of memory space required to execute the algorithm. The memory space occupied by the algorithm includes the space occupied by the algorithm program, the storage space occupied by the initial data entered, and the extra space required during the execution of the algorithm, such as the working unit in the execution process and the additional storage space needed for a data structure.
Complexity of the algorithm