We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 49962d5 commit 9ea5555Copy full SHA for 9ea5555
docs/14_树与二叉树/btree.py
@@ -72,12 +72,12 @@ def preorder_trav_use_stack(self, subtree):
72
if subtree:
73
s.push(subtree)
74
while not s.empty():
75
- peek = s.pop()
76
- print(peek.data) # 注意这里我用了 print,你可以用 yield 产出值然后在调用的地方转成 list
77
- if peek.right:
78
- s.push(peek.right)
79
- if peek.left:
80
- s.push(peek.left)
+ top_node = s.pop()
+ print(top_node.data) # 注意这里我用了 print,你可以用 yield 产出值然后在调用的地方转成 list
+ if top_node.right:
+ s.push(top_node.right)
+ if top_node.left:
+ s.push(top_node.left)
81
82
def inorder_trav(self, subtree):
83
if subtree is not None:
0 commit comments