Question: public class Tree { private Node root; private class Node { private int value; private Node leftChild; private Node rightChild; protected Node( int value) {
public class Tree {
private Node root;
private class Node { private int value;
private Node leftChild;
private Node rightChild;
protected Node(int value) {
this.value = value;
leftChild = null;
rightChild = null;
}
}
public Tree() {
root = null;
}
}
Write a hasValue() method that takes an integer value and returns true or false depending on whether the value argument can be found in the tree. Use a recursive helper function for the search.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
