Backtrack Search Algorithm
Backtrack Search Algorithm
ALGORITHM
BACKTRACKING
Suppose you have to make a series of decisions, among
various choices, where
You don’t have enough information to know what to choose
Each decision leads to a new set of choices
Some sequence of choices (possibly more than one) may be a
solution to your problem
Backtracking is a methodical way of trying out various
sequences of decisions, until you find the correct one
that “works”.
BACKTRACKING
Backtracking is used to solve problems in which a
sequence of objects is chosen from a specified set so that
the sequence satisfies some criterion.
Backtracking is a modified depth-first search of a tree.
7
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…)