Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
深度优先遍历的范围更大还是回溯的范围更大?为什么?
The text was updated successfully, but these errors were encountered:
我的理解是:dfs是回溯思想的一种体现
个人拙见。
Sorry, something went wrong.
深度优先搜索:DFS 在一个搜索空间(可以是树,也可以是图)的状态空间树上进行搜索,从根节点开始沿着左子树搜索,搜索到叶子节点会回溯到上一个父节点,然后再搜索该父节点的右子树,以这种方式搜索完整个树。深度优先搜索通常是搜索完整个树,但是也可以加上限制调节,得到第一个解即返回,这样的话,DFS在某种意义上就是回溯法。
回溯法 回溯法是按照深度优先搜索的方式进行搜索,如果当前搜索路径上已经没有解,则进行回溯,然后继续搜索。
其实没必要硬去区分它们的区别,我觉得只是这两种方式强调的思想不一样。 DFS更强调搜索方式 而回溯法更强调回溯的策略(也即剪枝的策略),让搜索方式更优,搜索的更快。 因此,回溯搜索的范围更小。
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
feat: azl397985856#378
37b2ebd
No branches or pull requests
azl397985856 commentedJun 1, 2020
深度优先遍历的范围更大还是回溯的范围更大?为什么?
The text was updated successfully, but these errors were encountered: