# 后续遍历是,左右根,逆序是 根右左,
# 和前序遍历很像,利用前序遍历的方法实现根右左的遍历
# 然后逆序打印
def pos_order(root):
if not root:
print("")
stack = [] # 用来实现根右左的遍历
temp = [] # 中间结果
stack.append(root)
while len(stack):
pop = stack.pop()
temp.append(pop.val)
if pop.left != None:
stack.append(pop.left)
if pop.right != None:
stack.append(pop.right)
n = len(temp)
for i in range(n):
print(temp[n-1-i],sep=" ")