oleksii
7/4/2016 - 7:49 PM

Inorder binary tree traversal

Inorder binary tree traversal

def inorder(root):
  curr, stack = root, []
  while curr or stack:
    if curr: 
      stack.append(curr)
      curr = curr.left
    else:
      curr = stack.pop()
      yield curr
      curr = curr.right