From ac431200be4ac473cbbb46acd1c0c22259676010 Mon Sep 17 00:00:00 2001 From: YuJian Date: Mon, 18 Apr 2022 14:37:11 +0800 Subject: [PATCH] vault backup: 2022-04-18 14:37:11 --- .../深度优先遍历.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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