fix minor typo
This commit is contained in:
parent
6a261c80ae
commit
80550ff36f
@ -8,17 +8,17 @@ import sys, os.path as osp
|
|||||||
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
|
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
|
||||||
from include import *
|
from include import *
|
||||||
|
|
||||||
# 定义一个result数组用来存储遍历的结果
|
# 定义一个list数组用来存储遍历的结果
|
||||||
result = []
|
|
||||||
|
|
||||||
# 前序遍历
|
# 前序遍历
|
||||||
def preorder(root):
|
def preorder(root):
|
||||||
if root == None:
|
if root == None:
|
||||||
return []
|
return []
|
||||||
·
|
|
||||||
# 访问顺序:根结点 -> 左子树 -> 右子树
|
# 访问顺序:根结点 -> 左子树 -> 右子树
|
||||||
|
|
||||||
result.append(root.val)
|
list.append(root.val)
|
||||||
preorder(root.left)
|
preorder(root.left)
|
||||||
preorder(root.right)
|
preorder(root.right)
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ def inorder(root):
|
|||||||
# 访问顺序:左子树 -> 根结点 -> 右子树
|
# 访问顺序:左子树 -> 根结点 -> 右子树
|
||||||
|
|
||||||
inorder(root.left)
|
inorder(root.left)
|
||||||
result.append(root.val)
|
list.append(root.val)
|
||||||
inorder(root.right)
|
inorder(root.right)
|
||||||
|
|
||||||
# 后序遍历
|
# 后序遍历
|
||||||
@ -43,4 +43,4 @@ def postorder(root):
|
|||||||
|
|
||||||
postorder(root.left)
|
postorder(root.left)
|
||||||
postorder(root.right)
|
postorder(root.right)
|
||||||
result.append(root.val)
|
list.append(root.val)
|
||||||
|
Loading…
Reference in New Issue
Block a user