Question

Given the following ambiguous context free grammar (3x20) 1. (a) Explain why the grammar is ambiguous (b) Find an equivalent

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(a)

Derivations for string aab

  • S -> Ab -> Aab -> aab
  • S -> aaB -> aab

There is more than one leftmost derivation for one string. So, the grammar is ambiguous

(b)

A = a+
B = b
S = a+b + aab

Language = a+b

Grammar

S -> Ab
A -> Aa | a

(c) String = ab

Leftmost derivation

  • S -> Ab -> Aab -> aab

Derivation Tree

S
|
Ab
|
Aab
|
a

--------------------------------------
Hit the thumbs up if you are fine with the answer. Happy Learning!

Multiple questions found. Answered one. -- Policy of Chegg. Please post accordingly.

Add a comment
Know the answer?
Add Answer to:
Given the following ambiguous context free grammar (3x20) 1. (a) Explain why the grammar is ambiguous...
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
  • 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 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...

  • For the grammar <A> ::= <A><A> '+' | <A><A> '*' | 'a' and the string aa...

    For the grammar <A> ::= <A><A> '+' | <A><A> '*' | 'a' and the string aa + a* Give the leftmost derivation Give the rightmost derivation Give a parse tree Is the grammar ambiguous or unambiguous? (Justify your answer) Describe the language generated by this grammar

  • The following shows a context-free Tammar on {0, 1}. Show that the grammar is ambiguous by...

    The following shows a context-free Tammar on {0, 1}. Show that the grammar is ambiguous by generating 2 derivation sequences for word 00111. S > AS5 A → Al|0A101 The following is a context-free grammar on alphabet {a}. Use the string a +a- a to verify whether or not the grammar is ambiguous. AA+AA-AA The following is a gamar equivalent to the one shown above in problem (5). Is it ambiguous? Use a +a- a to verify it. A →...

  • 1. Give a context-free grammar for the set BAL of balanced strings of delimiters of three...

    1. Give a context-free grammar for the set BAL of balanced strings of delimiters of three types (), and . For example, (OOis in BAL but [) is not. Give a nondeterministic pushdown automata that recognizes the set of strings in BAL as defined in problem 1 above. Acceptance should be by accept state. 2. Give a context free grammar for the language L where L-(a"b'am I n>-o and there exists k>-o such that m-2*ktn) 3. Give a nondeterministic pushdown...

  • 3 points) Question Three Consider the context-free grammar S >SS+1 SS 1a and the string aa...

    3 points) Question Three Consider the context-free grammar S >SS+1 SS 1a and the string aa Give a leftmost derivation for the string. 3 points) (4 poiots) (5 points) (3 points) sECTION IWOLAttcmpt.any 3.(or 2) questions from this.scction Suppose we have two tokens: (1) the keyword if, and (2) id-entifiers, which are strings of letters other than if. Show the DFA for these tokens. Give a nightmost derivation for the string. Give a parse tree for the string i) Is...

  • Give a context free grammar for the language L where L = {a"bam I n>:O and...

    Give a context free grammar for the language L where L = {a"bam I n>:O and there exists k>-o such that m=2"k+n) 3. Give a nondeterministic pushdown automata that recognizes the set of strings in L from question 3 above. Acceptance should be by accept state. 4. 5 Give a context-free grammar for the set (abc il j or j -k) ie, the set of strings of a's followed by b's followed by c's, such that there are either a...

  • formal language automata 1. (15p) Consider the Context-free grammar G defined by: S → 0A1A1A1A A0A1A...

    formal language automata 1. (15p) Consider the Context-free grammar G defined by: S → 0A1A1A1A A0A1A a) Describe L(G). (5p) b) Convert G into a Pushdown Automaton (PDA). (10p)

  • Please answer any 7 of them ТОС Answer any 7 from the followings: 1. Regular expression...

    Please answer any 7 of them ТОС Answer any 7 from the followings: 1. Regular expression to NFA: i) ab(aUb)* ii) (aba U a)*ab 2. Explain and construct a generalized NFA, 3. NFA to regular expression 0 3 91 93 8 a 4. DFA to regular expression 011 5. Explain the rules of pumping lemma briefly with an example. 6. Give an example of right linear grammar and left linear grammar. 7. L(G) = {1*20 m >= 1 and >=1}....

  • In each of the following, find a Chomsky Normal Form (CNF) grammar equivalent to the given...

    In each of the following, find a Chomsky Normal Form (CNF) grammar equivalent to the given context-free grammar (CFG). 1. SaA Sab A+ ab | BA ASD BaS b 2. SAIC A → AaB AaC | B | a B Bb Cb (→ cclc 3. S → SabA; AAA bc | Bc; B → Aab | BS a

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