Skip to content

Commit

Permalink
Merge pull request #48 from yinwoods/master
Browse files Browse the repository at this point in the history
update 树的层次遍历
  • Loading branch information
taizilongxu authored Mar 22, 2018
2 parents b1d68d9 + 76939ef commit ef9685e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -1664,14 +1664,10 @@ tree = Node(1, Node(3, Node(7, Node(0)), Node(6)), Node(2, Node(5), Node(4)))
```python

def lookup(root):
stack = [root]
while stack:
current = stack.pop(0)
print current.data
if current.left:
stack.append(current.left)
if current.right:
stack.append(current.right)
row = [root]
while row:
       print(row)
       row = [kid for item in row for kid in (item.left, item.right) if kid]

```

Expand Down

0 comments on commit ef9685e

Please sign in to comment.