1. The data structure (data structure)
Efficiency of the process to solve the problems with the organization of the relevant data
Efficiency solutions to problems related to the efficiency with space
Ingenious solutions to problems related to the degree of efficiency with the algorithm
#include <stdio.h>
#include <time.h>
clock_t start, stop;
double duration;
int main ( void )
{
start = clock ( ) ;
stop = clock ( ) ;
duration = ( ( double ) ( stop - start) ) / CLK_TCK;
printf ( "算法所用时间为%f秒\n" , duration) ;
return 0 ;
}
2. The three elements of the data structure
The logical structure data (logical structure)
Linear structure: one to one relationship between the elements
Structure Graphics: many to many relationships between elements
Tree structure: one to many relationship between elements
Data storage structure (storage structure)
Sequential storage structure: Data Element is the address section of contiguous space (array) in the memory
Storage Structure: discrete data elements in the memory address, continuous (list) by logical pointer
Operational data (operation): data type allows operations (the completion of these operations is the algorithm used)
3. abstract data types (abstract data type)
type of data:
Set of data objects
Operation data set associated with a set
Abstract: Description of data types not dependent on the specific implementation method
Regardless of the machine to store data
Regardless of the physical structure of the data storage
Nothing to do with algorithms to achieve operating and programming languages
4. The method (algorithm)
A limited instruction set (Limitation)
Accept some input (no need to enter in some cases)
Generating an output (output to be generated)
Certain termination (enforceable) after a limited step
Each instruction must have a clear goal, not ambiguity, must be within the computer can handle it (certainty)
The measure of the merits of the algorithm
1. validity: the algorithm should meet the exact needs of the specific problems
2. Robustness: When you enter invalid data, the algorithm can make appropriate treatment
3. Readability: reading benefit others
4. The time complexity (time complexity) T (n) = O (f (n)): the program runs the length of time spent
Extensive use of cycle
Multiply and divide time consuming than addition and subtraction
Usually analysis is generally the worst time complexity
The space complexity (space complexity) S (n) = O (f (n)): a program storage unit occupies when executed length
A large number of recursive function calls
Creating a large number of variables or objects
6. The complexity of the representation of the progressive
T (n) = O (f (n) indicates the presence of a constant C> 0, n [0]> 0 such that if n> = n have T (n) <= C * f (n [0] time) (Function Upper Bound)
O(1) < O(log n) < O(n) < O(nlog n) < O(n^2) < O(n^3) < O(2^n) < O(n!) < O(n^n)
Complexity addition rule: T . 1 + T 2 = max (O (F . 1 ), O (F 2 ))
Complexity Multiplication Rule: T . 1 * T 2 = O (F . 1 * F 2 )
For a cycle time equal to the number of cycles multiplied by the complexity of the loop body code complexity
The complexity of the structure if-else if the judgment conditions depending on the complexity and complexity of both the leg portions, overall complexity, whichever is the largest