Reputation: 41
The solution says for every 'a' you read, push 2 a's into the stack . Finally when you encounter 'b' , pop an 'a'. But won't this give the output as a^n b^n? For example: Input = aabbbb On reading the a's , the stack will have four 4 a's , hence on popping one 'a' for every 'b' encountered , won't you get aaaabbbb?
Upvotes: 0
Views: 1368
Reputation: 1
The strings which are generated by the given language are:
L={abb,aabbbb,aaabbbbbb,….}
Here a’s are followed by double the b’s
Whenever ‘a’ comes, push any character here let ‘t’ two times in the stack and if ‘a’ comes again then the same process is repeated.
When ‘b’ comes then pop one ‘t’ from the stack each time.
Finally at the end of the string, if nothing is left in the STACK, then we can declare that language is accepted in the PDA.
The PDA for the problem is as follows:
The transition functions are:
δ(q0, a, Z) = (q0,ttZ)
δ(q0, a, t) = (q0,ttt)
δ(q0, b, t) = (q1,ε)
δ(q1, b, t) = (q1,ε)
δ(q1, ε, Z) = (qf,Z)
Explanation:
Step 1 : Consider the string: "aabbbb" which satisfies the given condition.
Step 2 : For input 'a' and STACK alphabet Z, push two t's into the stack.
Step 3 : For input 'a' and STACK alphabet 't', again push two t's into the stack. Push the two 't's into STACK: (a,t/ttt) and state will be q0. Now the STACK has "tttt".
Step 4 : For input 'b' and STACK alphabet 't', then Pop one 't' from STACK: (b,t/ε) and state will be q1.
Step 5 : For input 'b' and STACK alphabet 't' and state q1, then Pop one 't' from STACK: (b,t/ε) and state will remain q1
Step 6 : For input 'b' and STACK alphabet 't', then Pop one 't' from STACK: (b,t/ε) and state will be q1
Step 7 : For input 'b' and STACK alphabet 't' and state q1, then Pop one 't' from STACK: (b,t/ε) and state will remain q1
Step 8 : We reached end of the string, for input ε and STACK alphabet Z,
Go to final state(qf): (ε, Z/Z)
Upvotes: 0
Reputation: 1579
These a
are different. One is from the input, another is for the stack. They are probably with different font in your document. The push-down automaton has a stack. In this stack (Last In First Out: LIFO) it remembers information that it uses for guide of how to accept the input: Wikipedia.
The idea is as follows:
a
push into the stack two t
and move to the next characterb
one t
from the stack has to be popped.a
after b
, and you need at least one input characterHere the stack is used to remember
how many b
to pop: two times more then a
.
Upvotes: 1