pushing given string as starting node into queue
q . push ( str ) ; visit . add ( str ) ; while ( q . length != 0 ) { str = q . shift ( ) ; if ( isValidString ( str ) ) { document . write ( str + " " ) ;