开发者

Pushdown automaton for (a^n b^n)^m c^m

I'm stuck building the transition functions for this automaton.

I suppose I should stack a 1 for ea开发者_运维技巧ch a and unstack it for each b

The number of c's equals the number of ab pairs, so I think I should stack a 0 for each b I encounter. Thing is: how do I unstack 1s and add 0s at the same time?


Don't push a 0 onto the stack each time you encounter a b. Instead, push a 0 onto the stack each time you encounter a b and the stack is empty or the top of the stack is a 0.

So, using your nomenclature for aabbabcc:

read a push 1
read a push 1
read b pop 1
read b pop 1
stack is empty so push 0
read a push 1
read b pop 1 
top of stack is 0 so push 0
read c pop 0
read c pop 0

Stack is empty so we accept this string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜