Published on One Big Library. (http://onebiglibrary.net)
PDA misadventures [Solved!]
By dchud
Created 2006-05-16 08:37

Yesterday I had a final exam in a formal languages and automata course. I got through most of it okay, but got stuck on a PDA (pushdown automaton [1]). The problem:

Design a PDA over language {a,b} such that count(a) = (2 * count(b)) + 1.

Only one stack allowed.

I stared at it for well over an hour, nearly twice as long as the rest of the test combined (tracing SLR(0) processing is fun!). Ultimately, as time was running out, and I hadn't come up with a solution, I went with something that at least solved several of the test strings that ruled out at least 6-8 other failed solutions.

pda-from-final [2]

I *think* this "two pops are better than one" strategy doesn't work on strings that are mixed up a lot. Like, "abaa" leaves an empty stack when input exhausts, which will be rejected.

Lazyweb corraboration/rejection of the hunch that this is wrong would be *greatly* welcome. The dot source is attached in case anybody wants to suggest a correction.

[Update (2006-05-17)] Tony's correct version, described in his comment below, looks like this:

pda2 from final [3]

Tweaked dotfile attached, too.

AttachmentSize
pda-from-final.dot.txt [4]1.04 KB
pda2.dot.txt [5]1.14 KB

Trackback URL for this post:

http://onebiglibrary.net/trackback/71

Source URL (retrieved on 2008-11-20 06:38): http://onebiglibrary.net/story/pda-misadventures

Links:
[1] http://en.wikipedia.org/wiki/Pushdown_automaton
[2] http://www.flickr.com/photos/dchud/147557569/
[3] http://www.flickr.com/photos/dchud/148150967/
[4] http://onebiglibrary.net/files/pda-from-final.dot.txt
[5] http://onebiglibrary.net/files/pda2.dot.txt