What finite-state machine captures binary strings with equal numbers of '01' and '10'?

前端 未结 2 1357
[愿得一人]
[愿得一人] 2021-01-23 03:46

I need help designing a finite state machine that accepts binary strings containing as many occurrences of the pattern 01 as occurrences of the pattern 10

2条回答
  •  独厮守ぢ
    2021-01-23 04:31

    You may need to be more precise in your question with the language that describes your language, because this to me sounds a lot like the classic trick question to create a FSM that recognizes L={0^n1^n: n is a positive integer} or, in plain speak, some pattern followed by the same number of a different pattern.

    This cannot be done with a Deterministic or nondeterministic finite state machine because to count N you would need an infinite (or non finite) state machine.

    A Grammar can solve this issue. It would be as follows: S-> 01S10 S-> (epsilon) (goes away, in other words)

提交回复
热议问题