public Node search_data_var2(Comparable searchable, Node T){
if(T.getInfo()==searchable){
return(T);
}
else{
if(T.getInfo()==null){
return null;
}
if(T.getInfo().compareTo(searchable)>0){
search_data_var2(searchable,T.getLeft());
}
if(T.getInfo().compareTo(searchable)<0){
search_data_var2(searchable,T.getRight());
}
}
}
I need to make a method which finds a node with a specific value "searchable" and returns the node "T", when it contains it. If such a value doesn't exist, the function should return "null". I am in trouble however and don't know how to achieve this with a single method. The function above is what I wrote. The problem is that the method can't return Node and null in the same way.
It's not forbidden to use an external function to achieve this, but currently I don't have a good idea how to achieve this.