-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree
More file actions
30 lines (25 loc) · 853 Bytes
/
Copy pathtree
File metadata and controls
30 lines (25 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 树
树是一种典型的非结构化数据,常用于迭代计算。
## 二叉树的遍历
#### [94. 二叉树的中序遍历](https://leetcode-cn.com/problems/binary-tree-inorder-traversal/)
```python
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def __init__(self)
self.list1 = [] ## 空列表
def inorderTraversal(self, root: TreeNode) -> List[int]:
self.mid(root)
return self.list1
def mid(self,root: TreeNode):
if root is None:
return None
self.inorderTraversal(root.left)
#print(root.val)
self.list1.append(root.val)
self.inorderTraversal(root.right)
```