background image

template<typename Comparable> 

typename

 

BinarySearchTree<Comparable>::BinaryNode

 

BinarySearchTree<Comparable>::clone( BinaryNode *t ) const

{

    if( t==NULL )

        return NULL;

    return new BinaryNode( t->element,clone( t->left ),clone( t->right ) );

}

template<typename Comparable>

void BinarySearchTree<Comparable>::printTree( ostream & out = cout )const

{

        

        if( isEmpty() )

        out<<"Empty tree"<<endl;

        else

        printTree( root,out );

}   

template<typename Comparable>

void BinarySearchTree<Comparable>::printTree( BinaryNode * t,ostream & out ) const

{

    if( t!=NULL )

    {

        printTree( t->left,out );

        out<< t->element <<endl;

        printTree( t->right,out);

    }

}