2

I am trying to solve some problems in An Introduction to Formal Languages and Automata, by Peter Linz. In Section 2.1 (Deterministic Finite Acceptors), I cannot write the automaton and need help to solve it.

Question 17-(f), Chapter 2:

L = {w : |na(W) - nb(W)| % 3 < 2} 

na is the number of a characters in the word, nb is the number of b characters in the word.

I have solution but I don't know how to draw it here.

jbaums
  • 27,115
  • 5
  • 79
  • 119

1 Answers1

0

So we have 3 states: R0, R1, R2, which mean the remainders of the division by 3. Then we have our automaton with R0 the start state:

R0(a) -> R1
R0(b) -> R2
R1(a) -> R2
R1(b) -> R0
R2(a) -> R0
R2(b) -> R1

R0 and R1 are accepting states.

lunesco
  • 126
  • 3
  • 9