Question: Write a method size that returns the total number of nodes in the tree. For example, the following tree has a size of 8: +---+

Write a method size that returns the total number of nodes in the tree. For example, the following tree has a size of 8:

 +---+ | 6 | ___ +---+ ___ / \ +---+ +---+ | 3 | | 2 | +---+ +---+ / \ / \ +---+ +---+ +---+ +---+ | 1 | | 4 | | 6 | | 4 | +---+ +---+ +---+ +---+ \ +---+ | 0 | +---+ 

Assume that you are adding this method to the IntTree class as defined below:

public class IntTree{

private IntTreeNode overallRoot; //null for an empty tree

.........

}

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!