Give the diagram of transitions of a Turing machine to a ribbon which accepts the language on the alphabet $\{0, 1\}$ of the words which contain as many $0$ as of $1$. (Note well that the $0$ and the $1$ can appear in any order.)
This problem is similar to $\{0^n 1^n : n \in \mathbb{N}\}$ except the fact that we mix up all the $0$'s and $1$'s and can be solved with a simple pushdown automata. An instance of an accepting word on the tape would be $010011000111$ and a rejecting word would be $010111$.
I am confused how to set that up. I have thought building a transition with two states :
- $q_0$ would be the starting starting which is also the accepting state.
- $q_1$ would be the rejecting state.
I have thought using the transition function which will move left when I meet a $0$, move right when I meet a $1$ and using the symbol $\$$ whenever a state has been visited.
Am I on the right track? How to build such diagram?