mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
Update trie_postorder.py
This commit is contained in:
parent
a97c06f579
commit
728b441734
@ -3,7 +3,7 @@
|
|||||||
# author: bt3gl
|
# author: bt3gl
|
||||||
|
|
||||||
|
|
||||||
def postorder(self, root: 'Node') -> List[int]:
|
def postorder(self, root: 'Node'):
|
||||||
|
|
||||||
if root is None:
|
if root is None:
|
||||||
return []
|
return []
|
||||||
@ -11,9 +11,12 @@ def postorder(self, root: 'Node') -> List[int]:
|
|||||||
stack, result = [root, ], []
|
stack, result = [root, ], []
|
||||||
|
|
||||||
while stack:
|
while stack:
|
||||||
|
|
||||||
node = stack.pop()
|
node = stack.pop()
|
||||||
|
|
||||||
if node is not None:
|
if node is not None:
|
||||||
result.append(node.val)
|
result.append(node.val)
|
||||||
|
|
||||||
for c in node.children:
|
for c in node.children:
|
||||||
stack.append(c)
|
stack.append(c)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user