/* A program illustrating binary trees and recursion. Creates and print horizontally the following tree: root ______|_______ | | node1 node4 ___|___ | | | | node2 node3 node5 ___|___ | | node6 node7 */ class Node { public Object data; public Node left; public Node right; public Node (Object d, Node l, Node r) { data = d; left = l; right = r; } public void ptree (Node t, int pos) { if (t != null) { tab (pos); System.out.println (t.data); ptree (t.left, pos+1); ptree (t.right, pos+1); } } private void tab (int n) { for (int i=0; i