What is an algorithm (algorithm)
A description of the solution method (step) for a particular problem
Essence: A finite sequence of instructions in which each instruction represents one or more operations
algorithm Five features
- There are poor steps, every step has poor time
- deterministic directives must have a clear meaning and cannot exist ambiguity
- The operation described by the feasibility algorithm must be implemented by the implementation of the basic operation of a finite number of times to achieve
- Enter 0 or more inputs
- outputs one or more outputs, with certain specific relationships to the input
Description Method
- Natural language Description
- Formal language description
- Computer Programming Language Description
Algorithm Design Requirements
- Correctness (correctness)
- Readability (readability)
- Robustness (robustness)
- Versatility (generality)
- Efficiency and storage requirements
Measurement of algorithm efficiency
- Pre-analysis to find the time limit function
- Post-mortem testing
/** * @Brief * bubblesort * @Param a[] * @Param N * *voidBubblesort (intA[],intN) {bool change=false;intI=0, j=0; for(i=n-1, change=true; I>1&& change; I.) for(j=0, change=false; j<i; ++J)if(a[j]>a[j+1]) {a[j]^=a[j+1]^=a[j]^=a[j+1];//Exchange two numbersChange=true; }}
Data structure notes (i)