Last active
March 17, 2017 07:15
-
-
Save linnet8989/d345cb75b8985f2e42231493a1e150db to your computer and use it in GitHub Desktop.
深度优先搜索 代码编写指引
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
函数(参数:节点) | |
{ | |
定义:一个栈 | |
初始化:节点入栈 | |
搜索过程: | |
循环(当栈为不为空时继续) | |
{ | |
1. 栈顶出栈 | |
2. 此处插入验证(可在此处退出)条件 | |
3. 将出栈节点的子节点加入栈 | |
} | |
} | |
递归版: | |
dfs(参数:节点) | |
{ | |
1. 此处插入验证节点(可在此处返回)条件 | |
2. 遍历子节点 | |
{ | |
如果(子节点合法) | |
{ | |
dfs(子节点) | |
} | |
} | |
3. 此处插入返回值 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment