Skip to content

Instantly share code, notes, and snippets.

@AdelinGhanaem
Created June 29, 2016 07:56
Show Gist options
  • Select an option

  • Save AdelinGhanaem/463b5e7758c670d0824132c6b34702a0 to your computer and use it in GitHub Desktop.

Select an option

Save AdelinGhanaem/463b5e7758c670d0824132c6b34702a0 to your computer and use it in GitHub Desktop.
public class SimpleTreeFactory {
public static Node get() {
//the left part of the tree
Node leaf7 = new Node(null, null, 7);
Node leaf0 = new Node(null, null, 0);
Node node5 = new Node(leaf7, leaf0, 5);
Node node8 = new Node(null, node5, 8);
Node node7 = new Node(node8, null, 7);
//the right part of the tree
Node node1 = new Node(null, null, 1);
Node node2 = new Node(null, node1, 3);
return new Node(node7, node2, 5);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment