An example

Let's begin with an example that we have already seen in another module:


\begin{algorithm}
% latex2html id marker 76\begin{algorithmic}[1]
\STATE $x ...
...orithmic} \caption{A simple algorithm with a nested statement.}
\end{algorithm}

In this algorithm, line 2 marks the beginning of the prechecking loop, whereas line 4 marks the end of the prechecking loop. The statement on line 3 is contained within the prechecking loop. We can say that the assignment statement (on line 3 is nested inside the prechecking loop.

Note that use indentation to indicate that line 3 is contained within the construct that begins on line 2 and 4. Whenever we nest a statement inside another one, the nested (or embedded) one is indented by one additional level. Although this is not strictly a required syntax of pseudocode, it is commonly used and expected.



Tak Auyeung 2007-09-14