May Han
0
Q:

8-queens problem can be solved by

START
1. begin from the leftmost column
2. if all the queens are placed,
   return true/ print configuration
3. check for all rows in the current column
   a) if queen placed safely, mark row and column; and 
      recursively check if we approach in the current 
      configuration, do we obtain a solution or not
   b) if placing yields a solution, return true
   c) if placing does not yield a solution, unmark and 
      try other rows
4. if all rows tried and solution not obtained, return
   false and backtrack
END
0

New to Communities?

Join the community