previous | start | next

Stack Application

8 queens problem

In chess a queen controls the row, the column, and the diagonals that intersect the position of the queen on the 8 x 8 chess board (8 rows, 8 columns).

Although each side only has 1 queen in chess, the 8 queens puzzle is to place 8 queens on the 8 x 8 chess board so that each row, column and diagonal contains at most one queen.

A solution can be found by placing one queen in each row, one at a time avoiding the columns and diagonals controled by the previously placed queens.

The problem is that this process may come to a row where every entry is already controlled by a previously placed queen.

The algorithm must then backup to the previous row and choose a different square for the queen in that row and try again.



previous | start | next