The way the language is defined, you need to constantly keep tabs of the difference between the number of 0s and 1s multiplied by two. Each 1 takes you to q_k-2 and each each 0 takes you to q_k+1.

The language is defined so any time during the run on the string that this difference (absolute value) is larger than 2, you're done, and you run out the rest of the string in a sink state. So if you're in q_2 and you get a 0, you're done, and the same if you're in q_-2 or q_-1 and you get a 1. So you need the states for the legit values of the difference {-2, â€¦, 2} and one extra sink state where the unworthy string can go to die.

]]>I've taken a look at the midterm and I can't understand the solution of the 4th question.

It's written that the language can be computed by a DFA with 6 states.

As I see it, there's a need of a stack to compute this language.

For example, the word 111110000000000000.

States that describe only {-2,-1,0,1,2} are not sufficient in this case.

Can someone please help me figure out what am I missing?

Thanks and Shabat Shalom!

]]>