Question: IN JAVA PLS Let's determine if a binary tree is height balanced . A tree is height balanced if the height of any node's two

IN JAVA PLS Let's determine if a binary tree is height balanced. A tree is height balanced if the height of any node's two subtrees (right and left) never differ by more than 1.

Provide a public class named BinaryTreeBalanced providing a single public class method named isBalanced. isBalanced accepts a BinaryTree and returns true if the tree is balanced, and false otherwise. If the passed tree is null, you should throw an IllegalArgumentException.

A few hints on this problem:

Your main entry point method will probably need to start the recursion using a private helper method, because the main method needs to throw on null which you want to handle as a valid base case in your recursion

This helper method will probably have the same arguments as the main method, so you'll need to change something else to make sure that the method signature is different and the compiler can determine which one you want to use

You will probably need a second helper method implementing tree height that you call in your primary recursive method

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!