Created
January 30, 2016 16:43
-
-
Save mding5692/cbc879a9b65a30281cda to your computer and use it in GitHub Desktop.
Western Tech Interview Prep Session 2 - Michael Ding : Includes tree traversals
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
void Inorder(Node root) { | |
if (root == null) { return;} | |
Inorder(root.left); | |
System.out.print(root.data + " "); | |
Inorder(root.right); | |
} |
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
void Postorder(Node root) { | |
if (root == null) { return; } | |
Postorder(root.left); | |
Postorder(root.right); | |
System.out.print(root.data + " "); | |
} |
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
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