Skip to content

Instantly share code, notes, and snippets.

@liondancer
Created January 2, 2017 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liondancer/16d8f4f5f3e062a47cd7259688aeaaa7 to your computer and use it in GitHub Desktop.
Save liondancer/16d8f4f5f3e062a47cd7259688aeaaa7 to your computer and use it in GitHub Desktop.
Binary Tree Inorder Iterative
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