Complete the code to check if the tree node is null.
if (root [1] null) { return true; }
We use '==' to check if root is exactly null, meaning no node exists.
Complete the code to calculate the height of the left subtree.
int leftHeight = height(root.[1]);We call height on the left child to get the left subtree height.
Fix the error in the condition that checks if the tree is unbalanced.
if (Math.abs(leftHeight - rightHeight) [1] 1) { return false; }
The tree is unbalanced if the height difference is greater than 1.
Fill both blanks to complete the recursive balance check for left and right subtrees.
return isBalanced(root.[1]) && isBalanced(root.[2]);
We check balance recursively on both left and right children.
Fill all three blanks to complete the height calculation method.
return 1 + Math.[1](height(root.[2]), height(root.[3]));
The height is 1 plus the maximum height of left and right subtrees.
