Created
January 2, 2017 00:52
-
-
Save liondancer/16d8f4f5f3e062a47cd7259688aeaaa7 to your computer and use it in GitHub Desktop.
Binary Tree Inorder Iterative
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def binary_tree_inorder_iterative(root): | |
res = [] | |
stack = [] | |
while root or stack: | |
if root: | |
stack.append(root) | |
root = root.left | |
else: | |
node = stack.pop() | |
res.append(node.val) | |
root - node.right | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment