GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Of the 92 solutions of the 8-queens problem (rotations and reflections counted separately), how many have no queen on either of the two main diagonals of the board?

  1. A. 92
  2. B. 28
  3. C. 8
  4. D. 12

Correct answer: D. 12

Enumerating all 92 solutions by backtracking and discarding any with a queen at (r, r) or (r, 7 − r) leaves 12. Excluding only one main diagonal leaves 28.

More Algorithms questions

Exams that ask this topic