beyondgrader.com Logo
DemoBrowseAboutTeamLogin

Binary Tree Count Non-Leaves

Geoffrey Challen // 2021.4.0

Create a public class BinaryTreeCounter that provides a single class method named countNonLeaves that accepts a single BinaryTree and counts the number of non-leaves in the tree. As a reminder, a leaf node has no children, so a non-leaf node has at least one child. If the passed tree is null, you can return 0, since an empty tree has no nodes and so no non-leaf nodes.

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