diff --git a/数据结构与算法之美/深度优先遍历.md b/数据结构与算法之美/深度优先遍历.md index e284b1a..bafb0a2 100644 --- a/数据结构与算法之美/深度优先遍历.md +++ b/数据结构与算法之美/深度优先遍历.md @@ -1,2 +1,17 @@ # 深度优先遍历 -TODO:占个位置以后再写 \ No newline at end of file +TODO:占个位置以后再写 + +```javascript +const node = { + name: "node 1", + children: [] +}; + +function DFS(node) { + console.log("探寻", node.name); + node.children.forEach(child => { + DFS(child); + }); + console.log("回溯", node.name); +} +``` \ No newline at end of file