回溯法
#584
Replies: 5 comments 3 replies
This comment was marked as off-topic.
This comment was marked as off-topic.
-
如果对回溯难以理解,说明对递归没有真正理解,出现了知识上的递归。不要对递归感到恐惧,应将递归视做处理问题规模无关和自相似性,能极大程度减少编码量的工具,而不是视为累赘和负担。如果实在难以理解,建议先复习高中的数学归纳法,并善用VS、CLion等IDE的并行堆栈、并行监视功能,它们都是帮助理解递归和回溯的优秀工具。加油。 |
Beta Was this translation helpful? Give feedback.
0 replies
-
这个N皇后问题写的是真优雅 |
Beta Was this translation helpful? Give feedback.
2 replies
-
我觉得给迷宫这道题用BFS首先就很迷惑,既然跟最短路无关,而且要求对独立的路径进行计数,这题当然是天生用DFS去做的。这道题用BFS+回溯算法实在是太抽象了,可以称得上是为了这碟醋,包了一顿饺子。有没有大佬可以提供一个看起来BFS相对于DFS有明显优势或者BFS和DFS相当的、需要使用回溯技巧的例子?我目前理解回溯算法几乎是和DFS强绑定的,希望能找到一个实用的BFS回溯的例子。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
https://oi-wiki.cf/search/backtracking/
Beta Was this translation helpful? Give feedback.
All reactions