Hint 2
- If the current node
r
is null, return false.
- If the current node
r
stores the targetElement
, return true;.
- If the left child of the current node is not null, then invoke the algorithm recursively with
parameter equal to the left child of the current node and
targetElement
. If the recursive
call returns true, then which value must be returned by the method? Do not return if the
recursive calls returns false (why)?
- Do the same thing with the right child of the current node.
- If the algorithm has not returned a value after the second call, then the method must return which value before it terminates?