The Gateway to Computer Science Excellence
0 votes
75 views

Consider the following language:

L = {w| w $\epsilon$ {0,1}* ; w has equal number of occurances of ‘001’ and ‘010’ }

The solution they provided: The absolute difference between the number of occurrences of ‘001’ and ‘010’ is at most 1. Hence a DFA can be found.

I did not get the solution. How is it possible? How do we maintain the count of the occurrences of any of these strings?

One approach I did think: To move forward if we get ‘001’ and move backward if we encounter ‘010’. But still, this approach will work only if I know in advance that “after a maxm of X occurrences of ‘001’, I am definitely going to find an occurrence of ‘010’ (and vice-versa)). But, since such info is not given, so how this can be a regular language?

closed as a duplicate of: made easy test series
in Theory of Computation by Active (1.2k points)
closed by | 75 views
0

1 Answer

0 votes
Best answer
When you write 001 twice 001001 there is 010 in between. If you write 010 twice 010010 you get 001 in between. So if you write n times anyone of the pattern the other pattern can be found either n+1 times or n times or n-1 times. You can construct nfa for this.
by (197 points)
selected by
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,650 questions
56,194 answers
193,988 comments
94,866 users