class Main_backup {
	public static void main(String args[]) {
		LinkedBinaryTree t = new LinkedBinaryTree();
		t.addRoot("a");
			t.insertRight(t.root(), "c");
			t.insertLeft(t.root(), "b");
				t.insertLeft(t.right(t.root()), "f");
				t.insertRight(t.left(t.root()), "e");
				t.insertLeft(t.left(t.root()), "d");
					t.insertRight(t.left(t.right(t.root())),"k");
					t.insertLeft(t.left(t.right(t.root())),"j");
					t.insertRight(t.right(t.left(t.root())), "i");
					t.insertLeft(t.right(t.left(t.root())), "h");
					t.insertRight(t.left(t.left(t.root())), "g");
		printTree(t);
	}
	
	public static void printTree(LinkedBinaryTree t) {
		int height = height(t, t.root());
		int x = 3 * height + height + 1;
		int y = (int)Math.pow(2, height) * 2 - 1;
		
		System.out.println("height: " + height + "\n");
		int nodes = findNodes(height);
		System.out.println("nodes:  " + nodes + "\n");
		System.out.println("x:      " + x + "");
		System.out.println("y:      " + y + "\n");
		
		recursive(t, t.root());
	}
	
	public static int depth(LinkedBinaryTree tree, Position node) {
		if(tree.isRoot(node))
			return 0;
		else
			return 1 + depth(tree, tree.parent(node));
	}
	public static int height (Tree T, Position v) {
		if (T.isExternal(v))
			return 0;
		else {
			int h = 0;
			Iterator children = T.children(v);
			while (children.hasNext())
				h = Math.max(h, height(T, (Position) children.next()));
			return 1 + h;
		}
	}
	
	public static int findNodes(int h) {
		int result = 0;
		while(h != -1) {
			result = result + (int)Math.pow(2, h);
			h--;
		}
		return result;
	}
	
	public static void recursive (Tree T, Position v) {
		if (T.isExternal(v) && )
			return 0;
		else {
			int h = 0;
			Iterator children = T.children(v);
			while (children.hasNext())
				h = Math.max(h, height(T, (Position) children.next()));
			return 1 + h;
		}
	}
}