Kotlinlearncs.online LogoJava
Return to List

Solve: Binary Tree Sum Right Child

Created By: Pranav Narayanan
/ Version: 2025.2.0

Create a public class TreeSumRightChild that provides a single class method named sumRightChild. sumRightChild accepts a single BinaryTree<Integer>. If the passed tree is null, throw an IllegalArgumentException. Otherwise, return the sum of the values in every node that is a right child. You may need to write a private helper method to solve this problem.

For reference, cs125.trees.BinaryTree has the following public properties:

Related Lessons

Stuck? You may find these lessons helpful:

Report a Problem

Attribution must link to this page: https://www.learncs.online/solve/java/binary-tree-sum-right-child/[email protected]