I had an assignment in which I had to design a pushdown automata that recognizes the language ${w \in [a,b,c]^*|w }$ have the same number of "ab" and "ba".
Tried to make a pushdown automata that if reads first ab pushes 1 to the stack and then if finds "ba" then pops it (and again reads "ab" and then "ba" , push / pop ) and the same if reads first "ba" and pops if finds "ab",but this approach fails for the case : ${baababbabaab}$ and many more cases. If someone could find whats wrong with my approach