go to previous page   go to home page   go to next page

Does '1' < '5' evaluate to true or false?

Answer:

true


Back to the Automaton

Finite Automaton

Here is the recognize() method as we left it, with a few blanks to be filled in.

  public boolean recognize(String str)
  {
    final int reject = 3;
    int  state = 0;
    char current;

    while ( ... )
    {
      current = next character in the string;

      // State 0
      if      ( state==0 && current=='a' )
        state = 1;

      // State 1
      else if ( state==1  && current >= 'a' && current <= 'y')
        state = 1;

      else if ( state==1  && current == 'z')
        state = 2;

     // State 2
      else if ( state==2  && __________ &&  __________ )
        state = 1;

      else if ( state==2  && __________ )
        state = 2;

      // no transition 
      else
        state = reject ;
    }

  }

QUESTION 10:

Mentally fill in the blue blanks.