Backtracking Algorithm

Backtracking is a general algorithm for finding all (or some) solutions to some computational problem, that incrementally builds candidates to the solutions, and abandons each partial candidate c ("backtracks") as soon as it determines that cannot possibly be completed to a valid solution.


Backtracking can be applied only for problems which admit the concept of a "partial candidate solution" and a relatively quick test of whether it can possibly be completed to a valid solution. It is useless, for example, for locating a given value in an unordered table. When it is applicable, however, backtracking is often much faster than brute force enumeration of all complete candidates, since it can eliminate a large number of candidates with a single test.



Backtracking is an important tool for solving constraint satisfaction problems, such as crosswordsverbal arithmetic,Sudoku, and many other puzzles. It is often the most convenient (if not the most efficient) technique for parsing, for the knapsack problem and other combinatorial optimization problems. It is also the basis of the so-called logic programming languages such as IconPlanner and Prolog. Backtracking is also utilized in the (diff) difference engine for the MediaWiki software.



Basic Problem:

Eight queens pluzzle
Sudoku
Knapsack
.....


Basic Idea:

Only compute the eligible candidates, thus if the candidates are not valid for the constraint, abandon it.
Method as if push_back(obj), recursive call, than pop_back()...

Comments

Popular posts from this blog

Wizard