This is a question from a past paper. I am struggling to get my head around the concept of a PDA. I understand that it is a Finite Automaton with a stack but am stuck as far as answering questions like this one. Thanks.
2 Answers
I think the answer is a, $\{a^n b^{2n} | n > 0\}$.
First, the machine pushes $a$'s onto the stack until the first $b$. Then, for every two $b$'s in the string, it pops off one $a$. Then, if the machine is at the end of the string and the stack is empty, it accepts.
If the stack of $a$'s runs out while the machine is still popping pairs of $b$'s or there are $a$'s left in the stack when the last $b$ is popped, then the machine rejects.
I am struggling to get my head around the concept of a PDA.
Notation varies, but in the diagram you provided, I think nop
means "read the thing on top of the stack and leave it there" and pop
means "read and remove the thing on top of the stack".
For more info, you could read the chapter on PDA's in Michael Sipser's book Introduction to the Theory of Computation.

- 175
- 6
the ans is C push all a's and pop each a for each b, if the stack is empty when all b's are scanned. Then this CFG.
-
1Have you read the other answer? It seems to contradict yours. – Yuval Filmus Apr 08 '18 at 06:50