
This is an old HW question where I had to find out how many times the q\loop state was visited for each given string:
bb: 5
abab: 0
abba: 8
babbab: 11
I understand how the 1st string visits the state 5 times and the 2nd string is not accepted, but I don't know the process for the 3rd and 4th strings. I would really appreciate it if someone could just walk through the states visited for the 3rd or 4th string because I keep getting stuck
This PDA matches palindromes. How does it do it? It looks for
Pon the stack and replaces it with eitheraPaorbPb, then matchesaon the stack withain the input. Likewise forb. It replacesPnondeterminstically.Let's walk through #3. We'll focus on
Q_loop, which I'll just callLfor simplicity. The top of the stack will be the rightmost character.L, the input isabbaand the stack is$P. We will nondeterministically follow thee,P->atransition.abba, the stack is$aPa. We will follow thea,a->etransition.bba, stack:$aP. Followe,P->b.bba, stack:$abPb. Followb,b->e.ba, stack:$abP. Followe,P->e.ba, stack:$ab. Followb,b->e.a, stack:$a. Followa,a->e.$. Followe,$->eand accept in the next state.