beyondgrader.com Logo
DemoBrowseAboutTeamLogin

BinaryTree Count Greater Than

Geoffrey Challen // 2020.11.0

Create a method countGreaterThan that accepts a BinaryTree<Int>? and an Int and returns a count of the number of nodes in the tree that contain a value greater than the passed value. If the passed tree is null you should return 0.

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

As a result, tree.value is an Int which you can compare to the threshold value in the usual way.