public class BinaryTree {

    private BinaryNode root;
    
    public BinaryTree( ) {
	root = null;
    }
    public BinaryTree(Object item) {
	this.root = new BinaryNode(item);
    }
    public BinaryTree(Object item, BinaryTree tleft, BinaryTree tright) {
	merge(item,tleft,tright); 
    }
        
    // Taken from Weiss: Merge routine for BinaryTree class.
    // Forms a new tree from rootItem, t1 and t2. Does not allow t1 and t2
    // to be the same. Correctly handles other aliasing conditions.
    public void merge( Object rootItem, BinaryTree t1, BinaryTree t2 ) {
        if( t1.root == t2.root && t1.root != null ) {
            System.err.println( "leftTree==rightTree; merge aborted" );
            return;
        }
        // Allocate new node
        root = new BinaryNode( rootItem, t1.root, t2.root );
        // Ensure that every node is in one tree
        if( this != t1 )
            t1.root = null;
        if( this != t2 )
            t2.root = null;
    }

    public boolean isEmpty() {
        return root == null;
    }
    
    public BinaryNode getRoot() {
        return root;
    }
    public void setRoot(BinaryNode root) {
	this.root=root;
    }

    public int getHeight() {
	return root.getHeight();
    }

    public String toString() {
	return root.toString();
    }
    public String toTree() {
	return root.toTree();
    }
    
    public boolean naivefind(Object o) {
	return root.naivefind(o,root);
    }

} // Class BinaryTree