【文件属性】:
文件名称:Python 树的遍历递归和循环
文件大小:21KB
文件格式:PDF
更新时间:2021-01-21 16:47:24
循环 递归 遍历
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
###递归的形式 先序遍历 中序遍历 后序遍历
def preOrderRecursive(root):
if root == None:
return None
print(root.val)
preOrderRecursive(root.left)
preOrderRecursive(root