Step E3 arrow ← is the most important alternative operation (sometimes called assignment or restriction). "M ← n" means the current value of the variable M. When the algorithm E begins, the value of M and N is the number given by the original; but when it ends, it is generally, which will have different values. Arrows are used to distinguish between alternative computments: we will not say "= N", but maybe we will ask "whether m = n?" "=" Mark a tested condition, "← "Tag a action that can be performed. The operation of N increase 1 is marked by "n ← n 1" (read as N 1 instead of N). Generally, "variable ← format" means calculating the bonus with the current value of all variables in the formula, and replacing the result of the original value of the variable on the left side of the arrow. People who are not familiar with computer work sometimes have such a tendency, that is, "N → N 1" to mark N-increased 1 operation, saying "N becomes n 1", which can only lead to confusion because it is standard The agreement is conflicting, so we should avoid it.
Note that the order of the operations in step E3 is important. "Play M ← n, n ← r" is completely different from "set n ← r, M ← n". Because the latter means that the original value of n has lost before using the value of n. Therefore, the latter order is equivalent to "set n ← r, m ← r". When several variables are all equal to the same amount, we use multiple arrows; so "n ← r, M ← r" can be written as "n ← M ← r". The value of the two variables exchange, we can write "exchange M <-> n"; this action can also be determined by using a new variable T, and writing "set T ← m, M ← n, n ← T" to determine .
Unless otherwise stated, an algorithm is always at step 1, usually at step 1, and sequentially executed. In step E3, the mandatory "return step E1" illustrates the order of calculation in a clear manner. In step E2, the prerequisite for the condition "R = 0" is used as the operation; so if r ≠ 0, the remaining words of the sentence are not applied. Although there is no action here, we always understand: can be added as a self-evident sentence "if r ≠ 0, proceed to step E3".
Rough vertical line ■, appears at the end of step E3, used to indicate that the algorithm has ended and the body will continue.
At this point, we actually discuss the agreement of all the marks in the algorithm of this book, and only the remaining "with the" band-subscripted "item used to represent an ordered array element. Marker. Suppose we have n quota ν1, ν2, ..., νn; for the jth element νj, we often use the marker ν [J] instead. Similarly, the α [I, J] is sometimes preferred for the two-scaled markers such as αij. Sometimes, the variable uses the name of multiple letters and writes these letters into capital. For example, the TEMP can be a name for temporarily saving a variable of a calculated value, and the prime [k] can represent the number of kth quality, the like.
I will talk about so much in the form of algorithm; now let us realize an algorithm to see. It should be noted immediately that readers don't expect to read an algorithm as reading a novel. If it is in such an attempt, then he will understand the content that is being described in writing. An algorithm should be reliable, and learn an algorithm until the best way to thoroughly is repeated. When the reader encounters an algorithm, take the pen and paper immediately, find an example of this algorithm; usually give this example, or readers can easily imagine it. In order to understand a given algorithm, this is a simple and labor-saving method, empirical proves that other routes are unsuccessful. Therefore, let's find an example of algorithm E. Suppose we give M = 119 and N = 544. Let us get started by step E1 (readers now want to follow this algorithm as we will narrate in one step by step below). In this case, it is very simple to use N to m. It is simply too simple because the merchant is 0, and the remainder is 119. So R ← 119. We proceed to step E2, and due to r ≠ 0, step E2 does not act. At step E3, we set M ← 544, N ← 119. Obviously, if the number of commercials in M
Return to step E1, we found 544/119 = 4 and 68/119. So R ← 68. Step E2 will not be used again. And in step E3, we set M ← 119, N ← 68. The next round of R ← 51, and final M ← 68, n ← 51. Then, r ← 17, and M ← 51, n ← 17. Finally, when R ← 0, the algorithm ends at step E2 at 17 divided by 51. The biggest common cause of 119 and 544 is 17.
So a algorithm is like this. The modern meaning of the algorithm is very similar to the prescription, process, method, technique, procedure, procedure, but is only a little particularly special. A algorithm is a collection of poor rules, which specifies a sequence of arithmetic sequences that solve a particular type of problem; in addition, one algorithm has five important characteristics:
1) Paste an algorithm must always end after being executed. Algorithm E is met. Since the value of R is less than N after step E1, if r ≠ 0, the next time the step E1 is performed, the value of n has been reduced. The decline sequence of positive integers must last at the end. Therefore, for any given N raw value, step E1 is only performed. However, note that the number of steps can be made to be anyging; the huge M and N may make step E1 to perform millions of times.
(All of the other features of the algorithm, but may not have a poor step, it can be called "calculation method". In addition to giving an algorithm for the maximum common factor of two integers, the European miles also give the actual Equivalent to a geometric structure of algorithm E, but it is the step of finding the "maximum measures" of the length of the two line segments. This is a calculation method, because if the two lengths are "uniform" Then it will not terminate).
2) Each step of determining the algorithm must be exactly defined. For each case, the action to be performed must be strictly and free of mixing. The algorithms in this book should comply with this guideline. But because they are described in natural language, the readers may not accurately understand what the author's meaning is. In order to avoid this difficult, it is designed to describe the programming language or computer language designed in the form of the algorithm, and each statement has a very meaningful meaning. Many algorithms in this book will be given in natural language and in a computer language. When a compute method is described in a computer language, its expression is called a program. In the algorithm e, the deterministic guidelines mean: For example, it is applied to step E1, it is assumed that the reader knows exactly what is the meaning of M, and what is the remainder. In fact, if M and N are not integral, what is the meaning of this, there is no general agreement. What is the remainder of -π -8? 0 What is the remainder of 59/13? Therefore, deterministic guidelines mean that we must ensure that when step E1 is performed, the values of M and N are always integers. Press assumptions that this is correct at the beginning. After step E1, R is a non-negative integer. If you want to perform steps E3, R must also be non-0, so M and N are integrated, as required, is the integer.
(Endlessly)