Skip to content

Commit 9ea5555

Browse files
committed
change peek-> top_node
1 parent 49962d5 commit 9ea5555

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/14_树与二叉树/btree.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ def preorder_trav_use_stack(self, subtree):
7272
if subtree:
7373
s.push(subtree)
7474
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)
75+
top_node = s.pop()
76+
print(top_node.data) # 注意这里我用了 print,你可以用 yield 产出值然后在调用的地方转成 list
77+
if top_node.right:
78+
s.push(top_node.right)
79+
if top_node.left:
80+
s.push(top_node.left)
8181

8282
def inorder_trav(self, subtree):
8383
if subtree is not None:

0 commit comments

Comments
 (0)