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

Answer:

Because any non-deterministic automaton can be converted to a deterministic automaton.


Main Program

If you need to program a non-deterministic automaton, first convert it to a deterministic one. There is an algorithm you can use to do this, but usually it is easiest just to think a bit.

In most situations where an automaton is useful a straightforward deterministic automaton is what you need. For example, if an automaton controls a car engine, it should be clear what state follows the current state. Automobile engines do not backtrack.

Let us write a program that recognizes strings that:

The string to be tested will be a command line argument. Here is the main program:

class FSAtester
{
  public static void main (String[] args)
  {
    String str = null;
    FSAaz fsa = new FSAaz();

    str = args[0];

    if ( fsa.recognize( str ) )
      System.out.println("The string is recognized.");
    else
      System.out.println("The string is rejected.");
  }
}

The method recognize() of the FSAaz class takes a String object as an argument. It returns true or false depending on whether the characters in the String are accepted. Here is a sample run of the program:

C:\> java FSAtester abcdaxz
The string is recognized.

C:\>

QUESTION 3:

Will the following string be recognized?

aabcz