广度优先或深度优先搜索广度、深度

2023-09-11 03:13:09 作者:古城白衣少年殇

我知道这个算法的工作,但不能决定何时使用哪种算法?

I know how this algorithm works, but cant decide when to use which algorithm ?

有没有一些准则,其中一个比另一个或任何方面的考虑执行?

Are there some guidelines, where one better perform than other or any considerations ?

非常感谢。

推荐答案

如果你想找到最短的步数,或者如果你的树有无限的高度(或非常大),你应该先使用广度的解决方案。

If you want to find a solution with the shortest number of steps or if your tree has infinite height (or very large) you should use breadth first.

如果你有一个有限的树,要使用的内存量最小,那么你应该先使用深度遍历所有可能的解决方案。

If you have a finite tree and want to traverse all possible solutions using the smallest amount of memory then you should use depth first.

如果您正在寻找最好的棋招玩,你可以使用迭代深化这是一个组合两者。

If you are searching for the best chess move to play you could use iterative deepening which is a combination of both.

IDDFS结合深度优先搜索的空间效率和广度优先搜索的完整性(当分支因子是有限的)。

IDDFS combines depth-first search's space-efficiency and breadth-first search's completeness (when the branching factor is finite).

 
精彩推荐
图片推荐