I have the following regular expression for the set of all strings such that each block of five consecutive symbols contains exactly two 0's (consider the alphabet to be {0, 1}):




How should I convert this into an NFA? Please explain the steps behind it as well!

  • 1
    $\begingroup$ cs.stackexchange.com/q/137007/755 $\endgroup$
    – D.W.
    Mar 25, 2021 at 19:09
  • $\begingroup$ It would be better for you to show more independence when doing your homework. $\endgroup$ Mar 28, 2021 at 14:07
  • $\begingroup$ Where is your regular expression taken from? $\endgroup$ Mar 28, 2021 at 14:10
  • $\begingroup$ @YuvalFilmus this regular was provided to me by my friend who is doing this assignment with me. And I have just asked a conceptual question regarding converting a regular expression to an NFA, which is something I cannot understand well. So, could you please answer my question? $\endgroup$
    – Jayajit
    Mar 29, 2021 at 17:33
  • $\begingroup$ cs.stackexchange.com/a/13606/755 $\endgroup$
    – D.W.
    Dec 7, 2022 at 19:14

1 Answer 1


What you need is the Berry-Sethi algorithm, constructing the Glushkov's automaton.

However, for your problem, I'd consider constructing directly a DFA with $10 = \begin{pmatrix}5\\2\end{pmatrix}$ states corresponding to words of size 5 containing exactly two zeros, and a sink state (and maybe some other states for the begining of the reading).

The Glushkov's automaton on your regular expression will be very big.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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