二叉树的中序遍历-python
程序员文章站
2022-05-20 13:50:07
...
def mid_order(root):
if root == None:
print("")
stack = []
stack.append(root)
while len(stack) or root != None:
if root != None:
stack.append(root.left) # 只负责进
root = root.left
else:
pop = stack.pop() # 只负责出
print(pop.val)
root = root.left