# Binary Tree findNums() ERROR

Hey Experts,

I have a problem with my code
I have a binary tree which in its nodes have elements from an unsorted array
and i have to create a method which will take two integers and print all the numbers from the binary tree which are between those numbers
Actually thats what i did:

public E findNums(int min, int max)
{
if (max > maximum())
{
max = rootNode;
}
else if (min < minimum())
{
min = minimum();
}
else{
if ((leftNode >= minimum()) || (leftNode <= max))
{
return leftNode;
}
else if((rightNode >= min) || (rightNode <=max))
{
return rightNode;
}
else
{
return null;
}
}
}

If anyone knows how to solve my problem / correct my code it 'd be grateful

###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
If your tree is sorted in inorder
public E findNums(int min, int max, Node root)
{
if( root == null ){ return; }
if( root.data >= min ){
public E findNums(int min, int max,root.leftNode);
if( root.data <= max ){ System.out.println( root.data ); }
}
if( root.data <= max ){
public E findNums(int min, int max,root.rightNode);

}
}
0

Experts Exchange Solution brought to you by