Back Tracking

回溯法是一种可以找出所有(或一部分)解的一般性算法,

它采用试错的思想,尝试分步的去解决问题。在分步解决问题的过程中,当它通过尝试发现现有的分步答案不能得到有效的正确的解答的时候,它将取消上一步甚至是上几步的计算,再通过其它的可能的分步解答再次尝试寻找问题的答案(约束补偿)。

回溯法通常用递归的方法来实现。

回溯法试暴力搜索法中的一种,然而在适用的情况下,回溯通常比暴力枚举所有完整的candidates要快得多,since it can eliminate many candidates with a single test.

Backtracking is an important tool for solving constraint satisfaction problems, such as crosswords, verbal arithmetic, Sudoku. It is often a convenient 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 Icon, Planner and Prolog.

Reference

递归、回溯和DFS

猜你喜欢

转载自blog.csdn.net/qq_34276652/article/details/112708088