Question: Write a recursive method for the class BinaryTree that counts the number of times an object occurs in a tree. (Note that this method is

Write a recursive method for the class BinaryTree that counts the number of times an object occurs in a tree. (Note that this method is just for binary trees- not a more specific kind of tree.)

The method header is:

public int count(T anObject)

Hint: write a private helper method: countHelper(BinaryNodeInterface node, object) and review the BinaryTree class to review the instance variables provided.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!