广度优先或深度优先搜索 [英] breadth first or depth first search

查看:206
本文介绍了广度优先或深度优先搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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).

这篇关于广度优先或深度优先搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆