Skip to content

Instantly share code, notes, and snippets.

@wethinkagile
Created May 31, 2014 14:20
Show Gist options
  • Save wethinkagile/c27ddce0b0ebd7e00ac8 to your computer and use it in GitHub Desktop.
Save wethinkagile/c27ddce0b0ebd7e00ac8 to your computer and use it in GitHub Desktop.
def preorder(tree):
if tree:
print(tree.getRootVal())
preorder(tree.getLeftChild())
preorder(tree.getRightChild())
def postorder(tree):
if tree:
postorder(tree.getLeftChild())
postorder(tree.getRightChild())
print(tree.getRootVal())
def inorder(tree):
if tree:
inorder(tree.getLeftChild())
print(tree.getRootVal())
inorder(tree.getRightChild())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment