回溯和深度优先搜索有什么区别?
最佳答案
Backtracking是一种更通用的算法。
Depth-First search是与搜索树结构相关的回溯的一种特定形式。来自维基百科:
One starts at the root (selecting some node as the root in the graph case) and explores as far as possible along each branch before backtracking.
它使用回溯作为其处理树的方法的一部分,但仅限于树结构。
不过,回溯可用于任何类型的结构,其中可以消除部分域 - 无论它是否是逻辑树。 Wiki 示例使用了一个棋盘和一个特定问题 - 您可以查看一个特定的走法并消除它,然后回溯到下一个可能的走法,消除它,等等。
关于algorithm - 回溯和深度优先搜索有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1294720/