This is a past exam paper on binary search trees I am attempting. I have no way to check if the output is correct as I am not capable of building one of these things.
The question is in the title
class Tree{
Tree left;
Tree right;
int key;
public static int span(Tree tree)
{
if ( tree == null ){
return null;
}
if( tree.left != null)
int min = span(tree.left);
}
if( tree.right != null){
int max = span(tree.right);
}
return max - min;
}
}
Could anyone suggest what I need to change to get 5/5 marks :D - the only thing we have to do is write the span
method, the header was given for us.