开发者

How do I implement pushdown automaton in C#?

I want to code this for PDA. How would I do that in C#?

a^nbc^n (n>开发者_开发百科;=0) 


Algorithm:

Read one letter at a time from the input, in a loop.

Stage 1:

If the letter read is "a" then increment a counter, and repeat Stage 1. If the letter read is not "a" then proceed to the next part.

Stage 2:

If the letter read is "b" then proceed to the next stage. If the letter read is not "b" then the algorithm fails.

Stage 3:

If if the letter read is "c" then decrement the counter, and repeat Stage 3. If the letter read is not "c" then proceed to the next stage.

Stage 4:

If the counter is zero, then the algorithm succeeds, otherwise it fails.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜