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

Answer:

q0


Pseudocode

StatesInputs
abcall else
q0q1---
q1-q0q2-
q2--q2-

Pseudocode for a table-driven implementation is straightforward. For the current state and input ch, table[state][ch] is the next state.

get a string
ch = first character of string
state = q0;

while ( characters remain in the string && not in reject state )
{
  state = table[state][ch];       
  ch = next character of string 
}

if ( state==q2 && no more characters in string )
  string is accepted
else
  string is rejected

For example, with the input string "abac" the state changes from

The final state is reached when the string is exhausted, so the string is accepted.

 


QUESTION 3:

Will the pseudocode correctly handle an empty input string?