Question: Please help with this java code. Write a getDepth() method that returns the depth of the tree. The function should use a recursive helper function

Please help with this java code.

Please help with this java code. Write a getDepth() method that returns

Write a getDepth() method that returns the depth of the tree. The function should use a recursive helper function to find the depth. The helper function should take two arguments for the current Node, and an integer argument for the current depth. It should return the value of the depth argument if it has no children. (Otherwise it returns the greater of the depths of its children.) The root has depth 0. It should return -1 if the tree is empty

Coding questions (tree): The following questions assume that the above code for a binary search Tree already exists. public class Tree f private Node root; private class Node ( private int value; private Node leftChild; private Node rightChild; protected Node (int value) 1 this.value-value; leftChild-null; rightChild-null,; public Tree() root null

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!