public static void main(String[] args) { Node root = new Node(5); root.left = new Node(3); root.right = new Node(3); root.left.left = new Node(9); root.left.right = new Node(8); root.right.left = new Node(8); root.right.right = new Node(9); print(root); }
private static void print(Node root) { if (root == null) { return; } System.out.println(root.value); print(root.left); print(root.right); }
static class Node { int value; Node left; Node right; Node(int value) { this.value = value; } }