Pseudo Code rules: Note Keywords are not case sensitiveVariable declaration Statements:dim< variables > as < type > such as: Dim A as INTEGER;Assignment statement:< variables >=< expressions > such as: a = 1; or a <-1;input and output:Input and output;Simple operators:A + B > C;Compound Condition:(A < b) and (c < D);if condition clause:If a = B then i = i + 1; Else i = I-1endifMultiple Select Case clauses:Case < variable > ofcase 1: < condition > i = i + 1;case 2: < condition > i = i + 2; EndcaseFor loop clause:for< counter >=< start >To< end >< loop body >endforWhile loop clause:Do While < conditions > or while< loop body >endwhileUntil loop clause:do< loop body >Until< conditions >Algorithm Analysis:complexity of Time:tend to focus only on the worst-case run time, so only the longest time of the algorithm, focus on the most important growth levels, such as an²+ Bn + C, only focus on n²;commonly used symbols in algorithms:Asymptotic symbol:
(1) O symbol, asymptotically tight upper bound, f (n) = O (g (n)), indicating that there is a normal amount of C and n0 so that for all n≥n0, there is 0≤f (n) ≤CG (n), that is, less than Equals, f (n) is not higher than the Order of G (n);
(2) Ω symbol, asymptotically tight to the lower bound, f (n) =ω (g (n)), indicating that there is a normal amount of C and n0 so that for all n≥n0, there is 0≤CG (n) ≤f (n), that is, greater than or equal to, f (n) is not less than the order of G (n);
(3) O symbol, non-asymptotic tight upper bound, f (n) = O (g (n)), indicating the presence of normal quantities C and n0 so that for all n≥n0, there is 0≤f (n) < CG (n), i.e. less than, f (n) lower than g (n) of the order;
(4) Ω symbol, non-asymptotic compact lower bound, f (n) =ω (g (n)), indicates that there is a normal amount of C and n0 so that for all n≥n0, there is 0≤CG (n) < F (n), i.e. greater than, f (n) higher than the G (n) Order;
(5) Θ symbol, asymptotic tight bound, f (n) =θ (g (n)), indicates that there is a normal amount of c1,c2,n0 so that for all n≥n0, there is 0≤c1g (n) ≤f (n) ≤c2g (n), f (n) and g (n) the same order;
Examples of related uses of the asymptotic notation:
1. The time complexity of insertion sorting is O (n²), which represents the time complexity of the insertion schedule is a set of less than or equal to n² (1,n,n², etc.), the time complexity can be 1 or n²;
2, if the time complexity is θ (2n²), representing the time complexity can be n²,2n²,3n² and so on;
3, if the time complexity is Ω (n²), the representative of the time complexity can be n²,n^3 and so on;
4, if the time complexity is O (n²), representing the time complexity can be 1,n,2n, but not can n²;
5, if the time complexity is Ω (n²), representing the time complexity can be n^3,n^4, but not n²;
Standard notation and common functions:
1, the next rounding (floor) and rounding (ceiling);
2. Modulo operation: The value of a mod B is the remainder of a/b;
3. Divisible: a | b
4. Logarithm:
Euclidean algorithm:A greatest common divisor of two integers, equal to the greatest common divisor of the number of small integers divided by two integers; Proof:
A can be expressed as A = kb + R, then r = a mod b
Assuming D is a number of conventions for a, B, there are
D|a, d|b, and r = a-kb, so d|r
So d is the number of conventions (B,a mod b)
Assuming D is the number of conventions (B,a mod b), then
D | B, D |r, but a = KB +r
So d is also the number of conventions (A, B)
Pseudo-code and time complexity