mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-07-08 23:59:51 -04:00
Update trie_preorder.py
This commit is contained in:
parent
728b441734
commit
4e895726bd
1 changed files with 1 additions and 0 deletions
|
@ -11,6 +11,7 @@ def preorder(root: 'Node'):
|
||||||
stack, result = [root, ], []
|
stack, result = [root, ], []
|
||||||
|
|
||||||
while stack:
|
while stack:
|
||||||
|
|
||||||
node = stack.pop()
|
node = stack.pop()
|
||||||
result.append(node.val)
|
result.append(node.val)
|
||||||
stack.extend(node.children[::-1])
|
stack.extend(node.children[::-1])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue