Create a method named countChildSumToEven
that
accepts a single BinaryTree<Int>?
and counts the number of nodes in the tree where the values of the two
children sum to an even number.
You should not count nodes that don't have at least one child.
Keep in mind that not every node has a right or left child, so you'll need to check for null
carefully.
However, you can assume that all the values in the tree are Int
s.
For reference, cs125.trees.BinaryTree
is defined like this:
You're challenge is to write tests for this problem described above.
Stuck? You may find these lessons helpful: