First, the algorithm
Definition: A finite sequence of operations in order to solve certain types of problems specified
Features: finite, certainty, feasibility, input, output
Second, the basic criteria for evaluating the merits of the algorithm
Correctness, efficiency, readability, robustness
Third, the time complexity of the algorithm
Statement is repeatedly executed the number of times a statement called frequency (Frequency Count)
In general, the number of basic algorithms repeat the statement is a function of problem size n f (n), a measure referred to as time algorithm
T(n)=O(f(n))
It represents an increase in the age problem size n, the same algorithm execution time of growth and f (n) growth rate, called progressive time complexity of the algorithm, the complexity of the short time (Time Complexity)
T (n) and f (n) represents the function of the two positive integers, then T (n) = O (f (n)) represents a positive constant C and n0, such that when n> = n0 are satisfies 0 <= T (n) <= Cf (n)
This indicates that the function definition function T (n) and f (n) have the same growth trend, and T (n) tends to increase up to the function f (n) growth.
Analysis methods are:
Find the statement in the maximum frequency as all statements of the statement that the basis statement, calculation of the basic frequency to obtain a statement of function f (n) n is the problem size, take the order of the symbol "O" represents can.
If the execution time of the algorithm does not increase with the size of the problem of n and growth algorithms statement is a constant frequency. Are referred to as time complexity of O (1)
Time complexity of the algorithm is at best time complexities.
Time complexity of the algorithm in the worst case is the worst time complexity.
Average time complexity of the algorithm is the algorithm refers to all possible, to other examples according to the input probability, the amount of calculation algorithm weighted average.
Fourth, the space complexity of the algorithm
Space complexity (Space Complexity)
S(n)=O(f(n))