Backtrack Nqueen
Backtrack Nqueen
ALGORITHM
BACKTRACK
The term backtracking was coined by American
Mathematician D. H. Lehmer in 1950’s.
Backtracking is the approach of finding the
G1 B2 G1 B2 B1
B1
BACKTRACK
Let we have 3 kids (2 Boys, 1 Girl) and we have 3 Chairs.
B1 B2 G1
B1 G1
B2
B2 G1 B1 G1 B1 B
2
Bounding Kill
G1 B2 B1
function G1
S1 S2 S3 S4
of a tree.
It is the procedure whereby, after
24
BACKTRACKING EXAMPLE—8 QUEENS
PROBLEM(CONT…)
This problem can be solved by trying to place
the first queen, then the second queen so
that it cannot attack the first, and then the
third so that it is not conflicting with
previously placed queens.
BACKTRACKING EXAMPLE—8 QUEENS
PROBLEM(CONT…)
It is an empty 8 x 8
chess board. We
have to place the
queens in this
board.
BACKTRACKING EXAMPLE—8 QUEENS
PROBLEM(CONT…)
this way.
PARALLELIZING BACKTRACK
ALGORITHM
The solutions to the n-queens problem can be
generated in parallel by using the master-
worker technique.
The manager generates the upper portion of