0
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ You might find it helpful to have a look at this question and its answers. It expands on what's been said here and might show you how these problems are approached. $\endgroup$ – Rick Decker Feb 2 '17 at 20:06
2
$\begingroup$

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.

$\endgroup$
2
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ NO, I need that details, I am stuck with this from last 2 hours. $\endgroup$ – user123456987 Feb 2 '17 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.