Pseudocode
In order to apply backtracking to a specific class of problems, one must provide the data P for the particular instance of the problem that is to be solved, and six procedural parameters, root, reject, accept, first, next, and output. These procedures should take the instance data P as a parameter and should do the following:
- root: return the partial candidate at the root of the search tree.
- reject(P,c): return true only if the partial candidate c is not worth completing.
- accept(P,c): return true if c is a solution of P, and false otherwise.
- first(P,c): generate the first extension of candidate c.
- next(P,s): generate the next alternative extension of a candidate, after the extension s.
- output(P,c): use the solution c of P, as appropriate to the application.
The backtracking algorithm reduces then to the call bt(root(P)), where bt is the following recursive procedure:
procedure bt(c) if reject(P,c) then return if accept(P,c) then output(P,c) s ← first(P,c) while s ≠ Λ do bt(s) s ← next(P,s)
http://www.cse.ohio-state.edu/~gurari/course/cis680/cis680Ch19.html
CROSSWORD PUZZLE PROBLEM
http://www.cis.temple.edu/~ingargio/cis587/readings/constraints.html
N QUEENS PROBLEM
http://faculty.cs.byu.edu/~ringger/Winter2008-CS312/lectures/Lecture31-backtracking.pdf
N QUEENS ,GRAPH COLOURING AND HAMILTONIAN CIRCUIT ALGORITHM
http://www.adeli.ir/courses/algorithms_fall2008/Chapter%205%20-%20Backtracking.pdf