Cognitive Scaffold

Preparing your thinking workspace

arrow_back_ios_new
MENTAL MODEL · M6025

Backtracking

Backtracking
CreateHigh supportInnovation Methods
Included
account_tree

Updated 2026-07-28

Loading revision record…

Summary

Backtracking is a type of brute-force search. For certain computational problems, backtracking is a general algorithm that can find all (or some) solutions, especially suitable for constraint satisfaction problems (in solving constraint satisfaction problems, we gradually construct more candidate solutions, and after determining that a certain partial candidate solution cannot be completed into a correct solution, we abandon continuing to search this partial candidate solution itself and its sub-candidate solutions, and instead test other partial candidate solutions). In classic textbooks, the eight queens problem demonstrates the use of backtracking.

Definition

Backtracking is a type of brute-force search. For certain computational problems, backtracking is a general algorithm that can find all (or some) solutions, especially suitable for constraint satisfaction problems (in solving constraint satisfaction problems, we gradually construct more candidate solutions, and after determining that a certain partial candidate solution cannot be completed into a correct solution, we abandon continuing to search this partial candidate solution itself and its sub-candidate solutions, and instead test other partial candidate solutions). In classic textbooks, the eight queens problem demonstrates the use of backtracking. (The eight queens problem is to find all distributions of eight queens on a standard chessboard such that no queen can attack another.) Backtracking adopts the idea of trial and error, attempting to solve a problem step by step. In the process of solving step by step, when it finds through attempts that the current partial answer cannot yield an effective correct solution, it will cancel the previous step or even several steps, and then try again through other possible partial answers. Backtracking is usually implemented with the simplest recursive method. After repeating the above steps, two situations may occur:

How to use

Backtracking is a type of brute-force search. For certain computational problems, backtracking is a general algorithm that can find all (or some) solutions, especially suitable for constraint satisfaction problems (in solving constraint satisfaction problems, we gradually construct more candidate solutions, and after determining that a certain partial candidate solution cannot be completed into a correct solution, we abandon continuing to search this partial candidate solution itself and its sub-candidate solutions, and instead test other partial candidate solutions). In classic textbooks, the eight queens problem demonstrates the use of backtracking.

Mechanism

Backtracking is a systematic method of trying to solve a problem: go deep along a path, and when encountering a dead end, go back to the previous step (undo the choice) and try a different branch. It is depth-first search plus 'trial and error - undo', suitable for constraint satisfaction and combinatorial problems.

Practice

In progress 0/5

Practice this model in one real situation:

Check to track your progress (stored locally)
Learning progress0%

Cases

  • Eight queens, Sudoku solving; path planning with backtracking when encountering obstacles.

Common pitfalls

  • Lack of pruning leads to combinatorial explosion; forgetting to undo state causes contamination.
Sources

Source support: Explicit

References currently contain only Wikipedia links; primary sources still need review.

  • link
    zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E5%9B%9E%E6%BA%AF%E6%B3%95ZH · Explicit
    verified
account_treeGenealogyexpand_more

RELATED MODELS