In
backtracking
Backtracking is a class of algorithms for finding solutions to some computational problems, notably constraint satisfaction problems, that incrementally builds candidates to the solutions, and abandons a candidate ("backtracks") as soon as it de ...
algorithm
In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
s, backjumping is a technique that reduces
search space, therefore increasing efficiency. While backtracking always goes up one level in the
search tree
In computer science, a search tree is a tree data structure used for locating specific keys from within a set. In order for a tree to function as a search tree, the key for each node must be greater than any keys in subtrees on the left, and les ...
when all values for a variable have been tested, backjumping may go up more levels. In this article, a fixed order of evaluation of variables
is used, but the same considerations apply to a dynamic order of evaluation.
Image:Backtracking-no-backjumping.svg, A search tree visited by regular backtracking
Image:Backtracking-with-backjumping.svg, A backjump: the grey node is not visited
Definition
Whenever backtracking has tried all values for a variable without finding any solution, it reconsiders the last of the previously assigned variables, changing its value or further backtracking if no other values are to be tried. If
is the current partial assignment and all values for
have been tried without finding a solution, backtracking concludes that no solution extending
exists. The algorithm then "goes up" to
, changing
's value if possible, backtracking again otherwise.
The partial assignment is not always necessary in full to prove that no value of
lead to a solution. In particular, a prefix of the partial assignment may have the same property, that is, there exists an index