Find a derivation tree in Example 5.1 ({S}, {a, b}, S, P), with productions The grammar...
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...
Homework. Section 5.1 #m}. Hint: Think of this language 1. Design a context-free grammar for the language {a" b n as the union of {a"b" | n > m} and {a") n<m}. 2. Consider the context-free grammar G = (N,T, P, S), defined by N = {S}, T = {a,b), and P = {S + Sbs | bSaS | }. Find derivations, and corresponding parse trees, for the following strings: aaabbb, bbbaaa, ababab. What is L(G)?
The following context-free grammar (CFG) generates palindromes. This CFG has the following rules: S → ε, S → a, S → b, ..., S → z, S → aSa, S → bSb, ..., S → zSz. On an example of a palindrome cattac, show, step-by-step, how this palindrome will be generated by this grammar.
Consider the context-free grammar G = (V, T, S, P) where V = {S}, T = {0, 1, 2, +, *} and with productions S -> S + S | S * S | 0 | 1 | 2 a) Show that the grammar is ambiguous b) Give an equivalent unambiguous grammar.
2. Let w 100101 and G be the context-free grammar whose productions are given below (Note that G is in Chomsky Normal Form) 2. SKY 7. K ->YC 8. K 1 3, C CY 4. C1 Draw a parse tree for w. a. b. Test membership of w in L(G) using CYK algorithm (CYK algorithm is discussed in Section 7.4.4 of the textbook). Write down your solution step by step by giving proper explanations. c. Which nonterminals in G can...
Conversions to CNF: Textbook problems: 7.1.1 - 7.1.4 (p. 275) 7.1.1) Find a grammar equivalent to the following, but with no useless symbols: S → AB | CA A → a B → BC | AB C → aB | b 7.1.2) Begin with the following grammar, then eliminate ε-productions, eliminate unit productions, eliminate useless symbols, then put the grammar into CNF. S → ASB | ε A → aAS | a B → SbS | A | bb 7.1.3)...
Consider the following context-free grammar with terminals {a, b, c, d} and start symbol S. S → W | X | Y | Z W → AW D | X | Y | Z X → BXD | Z Y → AY C | Z Z → BZC | ε A → a B → b C → c D → d (a) Give a derivation tree with input string: aaaabccddd (b) What language does this CFG recognize? Give a...
Construct a regular grammar G (a" b) c (aa bb)? VT, S, P) that generates the language generated by Construct a regular grammar G (a" b) c (aa bb)? VT, S, P) that generates the language generated by
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...
Please help me with the coding for LL(1)!! The given grammar was: P → PL | L L → N; | M; | C N → print E M → print "W" W → TW | ε C → if E {P} | if E {P} else {P} E → (EOE) | V (note: this has a variable O) O → + | - | * V → 0 | 1 | 2 | 3 (note: this has a terminal...