PDA to accept a language of strings containing more a's than b's

后端 未结 5 762
一生所求
一生所求 2021-02-11 01:30

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

5条回答
  •  盖世英雄少女心
    2021-02-11 02:12

    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.

提交回复
热议问题