Question: Create and test a method that simulates a general finite automaton. Your program should enable the computer to simulate any given finite automaton and then

Create and test a method that simulates a general finite automaton. Your program should enable the computer to simulate any given finite automaton and then to simulate, for any given word, step-by-step, how this automaton decides whether this word is accepted by the automaton.

The input to this method should include the full description of the corresponding finite automaton:

  • the number N of states; these states are q0, ..., qN − 1; we assume that q0 is the start state; for simplicity, we describe the states by the corresponding integers 0, ..., N;
  • the number M of symbols; these symbols are s0, ... sM − 1; for simplicity, we describe the symbols by the corresponding integers 0, ..., M;
  • an integer array state[n][m] whose elements describe to what state the finite automaton moves if it was in the state qn and sees the symbol sm; and
  • a Boolean array final[n] whose elements describe, for each state qn, whether this state is final or not.

When simulating a finite automaton, your program needs to keep track, at each moment of time, of the current state. Initially, the state is q0 -- which is described by number 0.

Turn in:

  • a file containing the code of the method, and
  • a file containing the result of testing this method.

Step by Step Solution

3.35 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres an example implementation of a method that simulates a general finite automaton in Python pyth... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!