@ Override protected void getHeights ( int currentHeight , List < Integer > heights ) { if ( isLeaf ( ) ) { heights . add ( new Integer ( currentHeight ) ) ; } else { if ( this . left != null ) { this . left . getHeights ( currentHeight + 1 , heights ) ; } if ( this . middle != null ) { this . middle . getHeights ( currentHeight + 1 , heights ) ; } if ( this . right != null ) { this . right . getHeights ( currentHeight + 1 , heights ) ; } } }
Replies the heights of all the leaf nodes . The order of the heights is given by a depth - first iteration .