Skip to content

Instantly share code, notes, and snippets.

@ssaurel ssaurel/Tree.java
Last active Apr 9, 2019

Embed
What would you like to do?
Tree Building for the Tree Traversal Algorithms in Java on the SSaurel's Channel
public class Tree {
public static void main(String[] args) {
// We create the nodes of our tree
Node<String> A = new Node<String>("A");
Node<String> B = new Node<String>("B");
Node<String> C = new Node<String>("C");
Node<String> D = new Node<String>("D");
Node<String> E = new Node<String>("E");
Node<String> F = new Node<String>("F");
Node<String> G = new Node<String>("G");
Node<String> H = new Node<String>("H");
Node<String> I = new Node<String>("I");
Node<String> J = new Node<String>("J");
Node<String> K = new Node<String>("K");
// Root and building of the tree
Node<String> root = A;
A.left = B; A.right = C;
B.left = D; B.right = E;
D.left = H; D.right = I;
E.left = J;
C.left = F; C.right = G;
G.left = K;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.