Problem 5 Suppose G is a context-free grammar, 2 is its set of terminals, and A...
2. Consider the following context free grammar with terminals (), +, id, num, and starting symbol S. S (ST) F-id Fnum a. Compute the first and follow set of all non-terminals (use recursion or iteration, show all the steps) Show step-by-step (the parsing tree) how the following program is parsed: (num+num+id)) b.
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...
TRUE OR FALSE? (Note: E = belongs to) 1. A context-free grammar G is in Chomsky normal form. Then G is not recursive. 2. Let G be an arbitrary context-free grammar. uAv =>* u'A'v' , where u, v, u' and v' E V* and A E (V - Eps), then L(G) is infinite. 3. {ww : w E {a, b}*} is accepted by some NDPDA with exactly two states
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...
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...
5. (5 points) Give context-free grammar that generate the following languages (1) (w is a binary string, and w starts and ends with the same symbol (2) the empty language (empty set)
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 →...
6. (5 points) Consider the context free grammar G = (V, E, R, S) where V is {S, A, B, a, b,c}, & is {a,b,c}, and R consists of the following rules: S + BcA S B +a → A S + b A+S Is this grammar ambiguous? swer. Justify your an-
Construct context-free grammars that generate the given set of strings. If the grammar has more than one variable, we will ask to write a sentence describing what sets of strings expect each variable in the grammar to generate. For example, if the grammar was: I could say "C generates binary strings of length one, E generates (non-empty) even length binary strings, and O generates odd length binary strings." It is also fine to use a regular expression, rather than English,...
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...