Data structure: The organization of a large number of methods;
Algorithm Analysis: Estimating the running time of the algorithm. involves computational efficiency.
Imagine, wouldn't it be amazing if you could reduce the time limit from 16 to less than 1 seconds?
One of the important ideas in many issues is that it is not enough to write a program that works. If the program is running on a huge data set, running time becomes an important issue.
An algorithm is a set of simple instructions that need to be followed to solve a problem that is clearly specified.
For a problem, once given an algorithm to determine that it is correct, then the next important step is the time and space for the algorithm to spend the amount of resources such as the problem
Definition: If there are positive integers C and n0, so that when N>=n0, T (n) <=CF (n), it is recorded as T (N) =o (f (n)) (note that the effect of constant c is omitted here)
When we say T (n) =of(n), we are guaranteeing that the function T (n) is growing at a rate that is not as fast as f (n); therefore, F is an upper bound of T.
as follows: T (n) =o (2n2) or T (n) =o (n2+n), are not customary and should be expressed as T (N) =o (N2)
Example of run time calculation:
Calculate an example of a i3 summation:
Sum (int N) { int i, partialsum; 0; // 1 for 1; I <= n;i++) //2 partialsum + + i*i*i; // 3 return Partialsum; // 4
The statement does not count for time, and the 1th and 4th lines account for 1 time units:
Line 3rd, 4 operations; Judging n times, 4N;
Line 2nd, initialize 1+n+n (self-increment), 2n+2;
Total: 2+4n+2n+2=6n+4; Therefore, we say that the function is O (N)
Data structure and algorithm analysis