Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class Node {
public Node left;
public Node right;
public int value;
public Node(int value, Node left, Node right){
this.value = value;
this.left = left;
this.right = right;
public Node(int value){
this.value = value;
public void print_depth_first(){
System.out.printf("%d, ", this.value);
if (this.left != null){
if (this.right != null){
public static void main(String[] args) {
Node n = new Node(1,
new Node(2,
new Node(3),
new Node(4)),
new Node(5));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment