From 7807b5e7989751cd9e5d2df8da6821438e01c378 Mon Sep 17 00:00:00 2001
From: jinbudaily <18336218010@163.com>
Date: Thu, 20 Jul 2023 15:53:16 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20=E4=BA=8C=E5=8F=89?=
=?UTF-8?q?=E6=A0=91=E7=9A=84=E9=80=92=E5=BD=92=E9=81=8D=E5=8E=86=20?=
=?UTF-8?q?=E6=8E=92=E7=89=88=E6=A0=BC=E5=BC=8F=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
problems/二叉树的递归遍历.md | 37 ++++++++++++++--------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/problems/二叉树的递归遍历.md b/problems/二叉树的递归遍历.md
index 92f342f0..730b18ac 100644
--- a/problems/二叉树的递归遍历.md
+++ b/problems/二叉树的递归遍历.md
@@ -4,15 +4,15 @@
参与本项目,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!
-
+> 一看就会,一写就废!
# 二叉树的递归遍历
+## 算法公开课
-《代码随想录》算法视频公开课:[每次写递归都要靠直觉? 这次带你学透二叉树的递归遍历!](https://www.bilibili.com/video/BV1Wh411S7xt),相信结合视频在看本篇题解,更有助于大家对本题的理解。
+**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[每次写递归都要靠直觉? 这次带你学透二叉树的递归遍历!](https://www.bilibili.com/video/BV1Wh411S7xt),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
-
-> 一看就会,一写就废!
+## 思路
这次我们要好好谈一谈递归,为什么很多同学看递归算法都是“一看就会,一写就废”。
@@ -109,14 +109,10 @@ void traversal(TreeNode* cur, vector& vec) {
可能有同学感觉前后中序遍历的递归太简单了,要打迭代法(非递归),别急,我们明天打迭代法,打个通透!
+## 其他语言版本
+### Java:
-
-
-# 其他语言版本
-
-
-Java:
```Java
// 前序遍历·递归·LC144_二叉树的前序遍历
class Solution {
@@ -171,7 +167,8 @@ class Solution {
}
```
-Python:
+### Python:
+
```python
# 前序遍历-递归-LC144_二叉树的前序遍历
# Definition for a binary tree node.
@@ -219,7 +216,7 @@ class Solution:
return left + right + [root.val]
```
-Go:
+### Go:
前序遍历:
```go
@@ -273,7 +270,7 @@ func postorderTraversal(root *TreeNode) (res []int) {
}
```
-Javascript版本:
+### Javascript:
前序遍历:
```Javascript
@@ -327,7 +324,7 @@ var postorderTraversal = function(root) {
};
```
-TypeScript:
+### TypeScript:
```typescript
// 前序遍历
@@ -370,7 +367,7 @@ function postorderTraversal(node: TreeNode | null): number[] {
}
```
-C:
+### C:
```c
//前序遍历:
@@ -422,8 +419,9 @@ int* postorderTraversal(struct TreeNode* root, int* returnSize){
}
```
-Swift:
+### Swift:
前序遍历:(144.二叉树的前序遍历)
+
```Swift
func preorderTraversal(_ root: TreeNode?) -> [Int] {
var res = [Int]()
@@ -473,7 +471,10 @@ func postorder(_ root: TreeNode?, res: inout [Int]) {
res.append(root!.val)
}
```
-Scala: 前序遍历:(144.二叉树的前序遍历)
+### Scala:
+
+ 前序遍历:(144.二叉树的前序遍历)
+
```scala
object Solution {
import scala.collection.mutable.ListBuffer
@@ -525,7 +526,7 @@ object Solution {
}
```
-rust:
+### Rust:
```rust
use std::cell::RefCell;