Initialize count of half nodes
int count = 0 ; while ( ! q . empty ( ) ) { struct Node * temp = q . front ( ) ; q . pop ( ) ; if ( ! temp -> left && temp -> right temp -> left && ! temp -> right ) count ++ ;