What is the complexity of time space?
"1" space complexity O(N):
A measure of the size of a storage space that is temporarily occupied by an algorithm while it is running. The spatial complexity of an algorithm only considers the size of the storage space allocated for the local variables during the run, including the storage space allocated for the parametric in the parameter table and the storage space allocated for the local variables defined in the function body two parts.
Example:
(1) If the spatial complexity of an algorithm is a constant, that is, does not change with the size of the processed data amount N, can be represented as O (n)
(2) when the spatial complexity of an algorithm is proportional to the logarithm of the base n of 2 , it can be represented as O (log2n)
(3) when the spatial complexity of an algorithm is linearly proportional to n , it can be represented as O (n)
(4) The time complexity of the recursive function is O (N), because each recursive need to save the internal variables of the function storage space.
time complexity of "2"
It quantitatively describes the running time of the algorithm. The number of iterations of the algorithm's basic operation is a function f (n)of module n , so the time complexity of the algorithm is recorded : T (n) =o (f (n)). As the module n increases, the growth rate of the algorithm execution is proportional to the growth of f (n) , so the smaller the f (n) , The lower the time complexity of the algorithm, the higher the efficiency of the algorithm.
The common time complexity is :
Constant Order O ( 1), logarithmic order O (log2n), linear order O (n),
Linear logarithmic Order O (nlog2n), Square order O (n^2), cubic o (n^3),... ,
K -order O (n^k), index order O (2^n). With the increasing of the problem scale n , the complexity of the time is increasing and the efficiency of the algorithm is less.
The interpretation of time-space complexity