Java Programming
Exercise 2
Another co-worker emails you and said she developed a recursive version for doing search in a binary search tree. Here’s the code for the function:
public boolean searchRecursive(Node current, int searchValue)
{
if (current.data == searchValue)
return true;
else if (current == null)
return false;
else if (current.data > searchValue)
return searchRecursive(current.left, searchValue);
else
return searchRecursive(current.right, searchValue);
}
She says that she “keeps getting an error” but unfortunately did not say if it was a compile error or a run-time error (or both). You analyze the code and see there is indeed an error and so you reply with the following:
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here