
320 Design and Analysis of Algorithms
o 1 . . With q1 in position now we try to put q2, following the same
o o o 2 steps as before.
. . . .
. . . . Then we have to put q3:
. 1 . . We can place her in the first position, as shown.
. . . 2
3 . . . Then to place q4, we again search and after
. . . . rejecting col.1 and col.2, we put it in col.3
. 1 . . So the final solution vector is:
. . . 2 (2, 4, 1, 3)
3 . . .
o o 4 .
Stages in a Backtracking solution of 4-queen problem
In the given example (Sec. 12.3.1), wherever we have put o in the matrix, it denotes a backtracking
point, that is, we have rejected a partial ...