How to desgin a turing machine that can recognize the strings of balanced parenthesis? For example (())().
To recognize the strings of balanced parentheses, we just have to make sure there is no prefix which has more closing parentheses than opening parentheses and that the string ends after seeing an equal number of opening and closing parentheses. Clearly, both of these conditions must hold of valid strings; these are necessary requirements. I will leave showing these conditions are sufficient as an exercise or, at any rate, suggest you ask a separate question on that.
So, all we need to do is the following:
Assuming a single-tape TM, you can read a symbol, then write over it with some marker, then move to the end of the tape in a state depending on whether you saw an opening or closing parenthesis; then, either add a new symbol to the end (if opening) or delete one off the end (if closing); then, enter a new state to go back to the first unmarked symbol of input, and repeat.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.