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:
null
which you want to handle as a valid base case in your recursion