extra NULL is pushed to keep track of all the nodes to be pushed before level is incremented by 1
q . push ( NULL ) ; while ( ! q . empty ( ) ) { node * temp = q . front ( ) ; q . pop ( ) ; if ( temp == NULL ) { if ( q . front ( ) != NULL ) { q . push ( NULL ) ; } level += 1 ; } else { if ( temp -> data == data ) { return level ; } if ( temp -> left ) { q . push ( temp -> left ) ; } if ( temp -> right ) { q . push ( temp -> right ) ; } } } return 0 ; }