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