- #1
tonedog12345
- 3
- 0
I can't figure out how to get these 2 methods to work. In my assignment description it says
public BinTree getLTree()
Get a reference to the left subtree. If this is not possible to do then throw an IllegalArgumentException.
NOTE
This routine returns a BinTree, not a Tnode. You will have to create a new BinTree and set its root to be a reference to the left subtree.
pre: fill this in...
post: fill this in...
Returns:
fill this in...
my BinTree constructors were correct and this is what they are
public BinTree()
{
root = null;
}
public BinTree( int val )
{
root = new Tnode( val, null, null );
}
this is what I put for the get functions
public BinTree getLTree()
{
if ( isEmpty() )
{
throw new IllegalArgumentException();
}
return new BinTree( root.getLkid().getVal() );
}
any suggestions please?
public BinTree getLTree()
Get a reference to the left subtree. If this is not possible to do then throw an IllegalArgumentException.
NOTE
This routine returns a BinTree, not a Tnode. You will have to create a new BinTree and set its root to be a reference to the left subtree.
pre: fill this in...
post: fill this in...
Returns:
fill this in...
my BinTree constructors were correct and this is what they are
public BinTree()
{
root = null;
}
public BinTree( int val )
{
root = new Tnode( val, null, null );
}
this is what I put for the get functions
public BinTree getLTree()
{
if ( isEmpty() )
{
throw new IllegalArgumentException();
}
return new BinTree( root.getLkid().getVal() );
}
any suggestions please?