Question

3. Construct a push down au gprnerated by a grammar with producti (npda) that accepts the lana B--b b. Show that the npda in
0 0
Add a comment Improve this question Transcribed image text
Answer #1

a. Here if from non-terminal S, the production S -> aSA happens total n times, then the output will be anSAn and then if S -> a production happen then the output becomes an+1An . And then each non-terminal A produce bB and hence output becomes (an+1(bB)n ). Since each B becomes b due to B -> b, hence the output will be an+1b2n .

Hence this grammar produce string of the form an+1b2n where n>= 0.

Below is the transition function of push-down automata to accept it.

\delta(q_0,a,Z_0) \rightarrow (q_1,Z_0) //On first input a, simply switch to state q1 .

\delta(q_1,a,Z_0) \rightarrow (q_2,aZ_0) //Push a into stack and move to state q2

(u,a, a2, aa)  //Push a into stack and move to state q2 even when top of stack contains a

\delta(q_2,\epsilon,a) \rightarrow (q_1,aa) //Push a into stack without consuming any input and go back to q1

Thus for even 'a' in the input, we are putting 'aa' into stack by going from q1 to q2 and coming back to q1 .

\delta(q_1,b,a) \rightarrow (q_3,\epsilon) //once b is encountered, then pop 'a' from stack and move to state q3

\delta(q_3,b,a) \rightarrow (q_3,\epsilon) //we will pop 'a' from stack for even 'b' in input

\delta(q_3,\epsilon,Z_0) \rightarrow (q_{accept},\epsilon) //Once entire input is over and stack contains only Z0 then this means input was in the form an+1b2n and hence accept the input.

b. We have already shown that above grammar generates an+1b2n and hence the push down automata accepts the above grammar.

Please comment for any clarification.

Add a comment
Know the answer?
Add Answer to:
3. Construct a push down au gprnerated by a grammar with producti (npda) that accepts the lana B--b b. Show that the npda in part a accepts the language a 0 RE 3. Construct a push down au gp...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Construct a NPDA with transition graph using 4 states that accepts the language L={w: na(w)-nb(w)=2} on...

    Construct a NPDA with transition graph using 4 states that accepts the language L={w: na(w)-nb(w)=2} on Σ={a,b} subject-- formal language of automata theory.

  • 1. For the following grammar: a) Give an example of a string accepted by the grammar. b) Give an ...

    Theory of Computation need ASAP 2-3 hours 1. For the following grammar: a) Give an example of a string accepted by the grammar. b) Give an example of a string not accepted by the grammar. c) Describe the language produced by the grammar. 2. Using the following grammar find a derivation for the string: 0001112 A0A1le C 0C2 | D Create a grammar for the language described by the following RE: Create a grammar for the following language: For the...

  • QUESTION THREE a. Construct a Push Down Automata that accepts L= {On In|n20; [10 Marks) b....

    QUESTION THREE a. Construct a Push Down Automata that accepts L= {On In|n20; [10 Marks) b. A finite-state machine can also be used to model a simple automated teller machine (ATM). Construct an FSM for an ATM that accepts deposits and withdrawals [10 Marks)

  • Q1: Given the below language and context free gramma:, a. Show that the grammar is ambiguous...

    Q1: Given the below language and context free gramma:, a. Show that the grammar is ambiguous using the string ( abc) by using substitutions. b. Then design a push down automata that recognizes the language. C. Then show the tracing of (abc, abbccc) using the push down automata. d. Then Show which two simple languages create the greaterlanguage. Give set builder notation for each language. e. Then produce Chomsky normal form for the grammar. The following context-free language is inherently...

  • 1. Consider the alphabet {a,b,c}. Construct a finite automaton that accepts the language described by the...

    1. Consider the alphabet {a,b,c}. Construct a finite automaton that accepts the language described by the following regular expression. 6* (ab U bc)(aa)* ccb* Which of the following strings are in the language: bccc, babbcaacc, cbcaaaaccbb, and bbbbaaaaccccbbb (Give reasons for why the string are or are not in the language). 2. Let G be a context free grammar in Chomsky normal form. Let w be a string produced by that grammar with W = n 1. Prove that the...

  • 1. Consider the following grammar A - aB B-Sb (a) Show a derivation tree for the...

    1. Consider the following grammar A - aB B-Sb (a) Show a derivation tree for the string aabbbb using the grammar. (b) Give an English description of the language generated by the grammar 2. Let G be the grammar below: S-ASB ab | SS (a) Show that G is ambiguous. (b) Construct an unambiguous grammar equivalent to G. 3. Find a context free grammar for the language L3- fa"b"c+m :n,m21) 4. Find a context free grammar for the language L4...

  • 1. Construct a DFSM to accept the language: L = {w € {a,b}*: w contains at...

    1. Construct a DFSM to accept the language: L = {w € {a,b}*: w contains at least 3 a's and no more than 3 b's} 2. Let acgt} and let L be the language of strings consisting of repeated copies of the pairs at, ta, cg, gc. Construct both a DFSM to accept the language and a regular expression that represents the language 3. Let a,b. For a string w E ', let W denote the string w with the...

  • 1. Construct a DFSM to accept the language: L w E ab): w contains at least 3 as and no more than 3 bs) 2. Let E (acgt a...

    1. Construct a DFSM to accept the language: L w E ab): w contains at least 3 as and no more than 3 bs) 2. Let E (acgt and let L be the language of strings consisting of repeated copies of the pairs at, ta, cg. ge. Construct both a DFSM to accept the language and a regular expression that represents the language. 3. Let ab. For a string w E , let w denote the string w with the...

  • Question2 in the photo. Please help. Thanks 1. Construct an NFA that accepts the language La...

    Question2 in the photo. Please help. Thanks 1. Construct an NFA that accepts the language La = {zaaabyaaabzla, y, z E {a, b)' } 2. Eliminate the e-transitions (denoted as E's below) from the following NFA s.t. the resulting machine accepts the same language with the same mumber of states. ql a,b go q3 2 3. Text problem: page 62, number 3. Finish by reducing the DFA. Note that you may want to do this in stages, first eliminating the...

  • (10] Eliminate left recursion from the grammar A Ba |Aa c B Bb | Ab 1...

    (10] Eliminate left recursion from the grammar A Ba |Aa c B Bb | Ab 1 d A Ad IB A BA ASJAE Consider the following grammar G: S'S S (S)S|e fa) (10] Construct the collection of the sets of LR(0) items (b) [5] When constructing the action table of SLR parser of G what are the rules to determine the parsing actions? That is, what is the rule for a shift action at state /? What is the rule...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT