0

We have to construct a DFA over the alphabet 0 and 1 for:

Every substring of four symbols has at most two 0's. For example, 001110 and 011001 are in the language, but 10010 is not since one of its substrings, 0010, contains three zeros.

I haven't reached to regular expression in the book which I am using. I am currently in unit 2 and regular expressions is from unit 3.

Gilles 'SO- stop being evil'
  • 43,613
  • 8
  • 118
  • 182

2 Answers2

2

Use the state of the automaton to "remember" enough information about the string that you've seen so far to allow you to determine whether the string you've read is in the language. This is true essentially independently of the language you're trying to recognize.

David Richerby
  • 81,689
  • 26
  • 141
  • 235
2

Intuitively, DFAs are machines that perform some computation, their limitation is the fact that they must use no memory. But since the substring size is fixed and finite, we can certainly check whether a string belongs to the language with a memoryless computation.

We only need to keep track of the last four symbols we read, and if there are too many zeros among those, we immediately reject the string: you can model that with a non-accepting state that only has transitions to itself.

I leave the details to you.

quicksort
  • 4,252
  • 1
  • 9
  • 21