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 getMax() method that returns the maximum value in the tree (or 0 if the tree is empty). The method should use a recursive helper function to find and return the max.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
