Question

Construct a PDA that accepts the language L = { w ∈ { a , b...

Construct a PDA that accepts the language L = { w ∈ { a , b } ∗ : n a ( w ) = n b ( w ) }, where n a ( w ) represents the number of a's that appear in the string w.

Homework Answers

Answer #1

PDA that accepts L(languages) = { w ∈ { a , b } ∗ : n a ( w ) = n b ( w ) }

Let 'a' or 'b' push in STACK. it means if 'a' comes first let it push in stack.
if after 'a' again 'a' comes then let push it .

If 'b' comes first, push it in STACK ('a' did not yet come)
If 'b' again comes then push b in STACK.

Now if 'a' is at the top of STACK and 'b' comes then, pop 'a'
Similarily if 'b' is at top of STACK and 'a' comes then, pop 'b'

So in the end of the strings if the STACK is empty then we can say that CFL is accepted in the PDA.

Now,We designed PDA for the problem:


STACK Transiton Function

                δ(q0, a, Z) = (q0, aZ)     
                δ(q0, a, a) = (q0, aa)     
                δ(q0, b, Z) = (q0, bZ)     
                δ(q0, b, b) = (q0, bb)     
                δ(q0, b, a) = (q0, ε)     
                δ(q0, a, b) = (q0, ε)     

                δ(q0, ε, Z) = (qf, Z)

STACK Transiton Function

       δ(q0, a, Z) = (q0, aZ)   
       δ(q0, a, a) = (q0, aa)   
       δ(q0, b, Z) = (q0, bZ)   
       δ(q0, b, b) = (q0, bb)   
       δ(q0, b, a) = (q0, ε)   
       δ(q0, a, b) = (q0, ε)   

       δ(q0, ε, Z) = (qf, Z)
We will take one input string: "aabbbbaa"

Scan string from left to right
Now at First input is 'a' and we follow the rule:
input 'a' and stack alphabet Z, push the input 'a' into the STACK as : (a,Z/aZ) and state is q0
Second input is 'a' and so we follow the rule:
input 'a' and STACK alphabet 'a', push the input 'a' into the STACK as : (a,a/aa) and state will not change remain q0
Second input is 'b' and so we follow the rule:
Third input is 'b' and so we follow rule
on input 'b' and STACK alphabet 'a', pop the STACK with one '"a" as : (b,a/&epsiloon;) and state will not change remain qo
Fourth input is 'b'
taking input 'b' and STACK alphabet 'a', pop the STACK with one "a" as : (b,a/&epsiloon;) and state will remain qo
Fifth input is 'b'
on input 'b' and STACK alphabet Z, push the input "b"into the STACK as : (b,Z/bZ) and state will remain q0
Sixth input is 'b'
on input "b" and STACK alphabet 'a', push the input "b" into the STACK as : (b,b/bb) and state will remain q0
Seventh input is 'a'
on input 'a' and STACK alphabet 'b', pop the STACK with one 'b' as : (a,b/&epsiloon;) and state will remain q0
Eighth input is 'a'
on input 'a' and STACK alphabet 'b', pop the STACK with one 'b' as : (a,b/&epsiloon;) and state will remain q0
We reached end of the string, so we follow the rule:
on input ε and STACK alphabet Z, go to final state(qf) as -> (ε, Z/Z)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Question 2 a) Construct a Pushdown Automaton (PDA) for the language L (M) = {a, b}*...
Question 2 a) Construct a Pushdown Automaton (PDA) for the language L (M) = {a, b}* where, if there are any a’s must precede all b's and the number of b's must be equal to or twice the number of a’s. a) Trace the computations for the strings aabb, bbb, and abb in the PDA obtained in Question 2
Construct a deterministic PDA for L = {w ∈ {a, b}* : na (w) = nb...
Construct a deterministic PDA for L = {w ∈ {a, b}* : na (w) = nb (w)}
Consider the language L = { w w : w ∈ { 0 , 1 }...
Consider the language L = { w w : w ∈ { 0 , 1 } ∗ } is not context-free. Note that this is the language of all strings that consist of some combination of 0s and 1s, followed immediately by that same combination of 0s and 1s. For example, 0101, 101101, and 110110 are all in the language because they consist of a string followed by itself. Can you build a PDA to recognize this language? (Hint: you...
Give an pushdown automaton (PDA) that will accept the following language: {w ∈ {a, b}∗ |...
Give an pushdown automaton (PDA) that will accept the following language: {w ∈ {a, b}∗ | w has twice as many bs as as}.
Construct an NFA for the following language: L = {w ∈ {a,b}∗ : every a is...
Construct an NFA for the following language: L = {w ∈ {a,b}∗ : every a is immediately followed by at most 2 b's}
Consider the language L3 over alphabet Σ = { a, b }, L3 = { w...
Consider the language L3 over alphabet Σ = { a, b }, L3 = { w ∈ Σ* | w is a palindrome of any length}. Construct a PDA that recognizes L3. Implement that PDA in JFLAP
Use CFG or PDA to prove L= {0a1b0c : b ≠ a + c; a, b,...
Use CFG or PDA to prove L= {0a1b0c : b ≠ a + c; a, b, c ≥ _0} is a context-free language. Please add your explanation, thank you. If you can use the theorem(union of CFL and regular language = CFL) is also welcomed.
PDA for L = {a^i b^j | i<j} PDA for L = {a^i b^j | i>j}
PDA for L = {a^i b^j | i<j} PDA for L = {a^i b^j | i>j}
The chopleft operation of a regular language L is removing the leftmost symbol of every string...
The chopleft operation of a regular language L is removing the leftmost symbol of every string in L: chopleft(L) = { w | vw ∈ L, with |v| = 1}. Prove or disprove that the family of regular languages is closed under the chopleft operation.    Hint: If it’s regular, give an idea of constructing an FA that accepts chopleft(L) using an FA M that accepts L. Otherwise, give a counterexample.
3. Consider the following “theorem". If L is a regular language then ∀ words w ∈...
3. Consider the following “theorem". If L is a regular language then ∀ words w ∈ L where |w| > 1 ∃ an expression w = xyz where (a) ∀i≥0.xyiz∈L (b) |y| ≥ 1 Explain whether this is a (true) theorem or not ( the question want us to explain why this theorem does not work alone)
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT