这是关于postorder_nonrecursive的代码。 我想知道预购和顺序像这段代码。 请帮帮我!
def postorder_nonrecursive(self):
if self == None:
return
stack = [[self,0]]
while len(stack) > 0:
node, state = stack[-1]
if state == 2:
yield node
stack.pop()
else:
child = (node.getLeft() if state == 0 else node.getRight())
stack[-1][1] += 1
if child != None:
stack.append([child,0])