Any suggestions for My search method?
This is my Binary search tree search method
Code:
public Node SearchBST(int number)
{
Node T = Root;
if (T == null)//If tree is empty
{
return null;
}
else
while(T != null){
if(number == T.data){
return T;
//Key found
}
else if(number < T.data){//Checks if the key is smaller than the current T
T = T.left;
}
else//Checks if the key is larger than the current T
T = T.right;
}
if(T == null)
return null;
//Key not found
}
Anything would be helpful... I am not sure if it even works, I haven't implemented the graphical part of the BST.