Example 3: netflow
This function is part of an ACM algorithm for net flow optimization.
The function has many input parameters configuring
the net to be optimized, for example connected nodes
and connection capacity. The two parameters are low and
high. The netflow function begins with some plausibility
checks on the input parameters. The flag variable violation
is typical of a test for ‘special conditions’ which cannot be
handled by the regular algorithm. In this case, it will be set
to true when low is set to a larger value than high. In this
case the ‘special condition’ is invalid input.
Example 4: moveBiggestInFront
The last example is part of a standard sorting algorithm.
A while loop processes the elements of an array, checking
whether the first element is the biggest. If no such value
exists, this constitutes a special case with the result that
the flag assignment is not executed in any iteration.