Produce a PDA to recognise the following language : the language of strings containing more a\'s than b\'s
I have been struggling with this
Your problem of "more a's than b's" can be solved by PDA.
All you have to do is:
When input is a
and the stack is either empty or has an a
on the top, push a
on the stack; pop b
, if b
is the top.
When input is b
and the stack is either empty or has an b
on the top, push b
on the stack; pop a
, if a
is on the top.
Finally, when the string is finished, go to the final state with null input if a
is on top of the stack. Otherwise you don't have more a
's than b
's.