note that the search condition in the while loop is modeled as procedure-function canbedone for maximal clarification of the logic of the algorithm while keeping the program easily comprehensible certainly the program can be optimized in other respects via appropriate equivalent transformations one canfor instanceeliminate the two procedures first and next by merging the two easily verifiable loops into one such single loop wouldin generalbe more complexbut the final result can turn out to be quite transparent in the case when all solutions are to be found (see the last program in the next sectionthe remainder of this is devoted to the treatment of three more examples they display various incarnations of the abstract schema and are included as further illustrations of the appropriate use of recursion the eight queens problem the problem of the eight queens is well-known example of the use of trial-and-error methods and of backtracking algorithms it was investigated by gauss in but he did not completely solve it this should not surprise anyone after allthe characteristic property of these problems is that they defy analytic solution insteadthey require large amounts of exacting laborpatienceand accuracy such algorithms have therefore gained relevance almost exclusively through the automatic computerwhich possesses these properties to much higher degree than peopleand even geniusesdo the eight queens poblem is stated as follows (see also [ - ])eight queens are to be placed on chess board in such way that no queen checks against any other queen we will use the last schema of sect as template since we know from the rules of chess that queen checks all other figures lying in either the same columnrowor diagonal on the boardwe infer that each column may contain one and only one queenand that the choice of position for the -th queen may be restricted to the -th column the next move in the general recursive scheme will be to position the next queen in the order of their numbersso try will attempt to position the -th queenreceiving as parameter which therefore becomes the column indexand the selection process for positions ranges over the eight possible values for row index procedure try (iinteger)begin if then initialize selection of safe and select the first onewhile ~(no more safe ~canbedone(ijdo select next safe end end end tryprocedure canbedone (ijinteger)boolean(*solution can be completed with -th queen in -th row*begin setqueentry( + )if not successful then removequeen endreturn successful end canbedone in order to proceedit is necessary to make some commitments concerning the data representation an obvious choice would again be square matrix to represent the boardbut little inspection reveals that