3

I am stuck with constructing an DFA that has at most in it.

The question I am stuck with is:

Design an DFA that accepts all strings over {0, 1} that contain at most two 00’s and at most three 11’s as a substring.

An answer in a form of a graph would be perfect but if someone can explain in plain words, I will appreciate that as well.

Gana
  • 39
  • 1

2 Answers2

2

You can use states of the form $(i,j)$ where $i$ counts the number of 00s and $j$ counts the numbers of 11s read so far.

Corristo
  • 151
  • 6
  • How can this be translated into a diagram? – Gana Aug 01 '15 at 17:44
  • 1
    In order to detect a substring 00 or 11 you need to know the last character as well. So introducing states $(i,j)_x$ denoting that the last character read was $x$, you just have to define the transitions accordingly: $$\delta( (i,j)_0, 0) = (i+1, j)_0, \delta ((i,j)_0, 1) = (i,j)_1 \ \delta((i,j)_1,0) = (i,j)_0, \delta((i,j)_1,1) = (i, j+1)_1 $$ Of course you have to include an initial state which is not of this form (you have not read a character yet) and an error state. – Corristo Aug 01 '15 at 19:34
1

This is a sadistic question...

It is easy to build a DFA over a, b for "at most 2 a" or "at most 3 b"; and build a DFA for the intersection (states are pairs of states, one of each automaton; transitions trace the first automaton in the first part of the state and of the second similarly; final states are composed of final states for both).

The same ideas (more complicated, but similar) give "at most two 00" or "at most three 11", and then build the intersection.

vonbrand
  • 14,004
  • 3
  • 40
  • 50
  • I'm not sure if I understand what you mean... Could you elaborate and maybe give some examples? – Gana Aug 01 '15 at 17:44