beyondgrader.com Logo
DemoBrowseAboutTeamLogin

BinaryTree Count Equal Children

Geoffrey Challen // 2021.10.0

Create a method named countEqualChildren that accepts a single BinaryTree<*>? and counts the number of nodes in the tree that have two children with the same value. Keep in mind that not every node has a right or left child, so you'll need to check for null carefully. (Or use try-catch!) However, you can assume that all of the values in the tree are non-null.

For reference, cs125.trees.BinaryTree is defined like this: