Skip to content

Instantly share code, notes, and snippets.

@mding5692
Created January 30, 2016 16:43
Show Gist options
  • Save mding5692/cbc879a9b65a30281cda to your computer and use it in GitHub Desktop.
Save mding5692/cbc879a9b65a30281cda to your computer and use it in GitHub Desktop.
Western Tech Interview Prep Session 2 - Michael Ding : Includes tree traversals
void Inorder(Node root) {
if (root == null) { return;}
Inorder(root.left);
System.out.print(root.data + " ");
Inorder(root.right);
}
void Postorder(Node root) {
if (root == null) { return; }
Postorder(root.left);
Postorder(root.right);
System.out.print(root.data + " ");
}
void Preorder(Node root) {
if (root == null) { return; }
System.out.print(root.data + " ");
Preorder(root.left);
Preorder(root.right);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment