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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!