Initialize count of half nodes
int count = 0 ; while ( ! queue . isEmpty ( ) ) { Node temp = queue . poll ( ) ; if ( temp . left != null && temp . right == null temp . left == null && temp . right != null ) count ++ ;