# Recent questions tagged ambiguous 1
The grammar $S\rightarrow aSb\mid bSa\mid SS\mid \varepsilon$ is: Unambiguous CFG Ambiguous CFG Not a CFG Deterministic CFG
2
Show that every DCFG is an unambiguous CFG.
3
Consider the following CFG $G:$ $S \rightarrow SS \mid T$ $T \rightarrow aT b \mid ab$ Describe $L(G)$ and show that $G$ is ambiguous. Give an unambiguous grammar $H$ where $L(H) = L(G)$ and sketch a proof that $H$ is unambiguous.
4
The following is an ambiguous grammar for expressions with $n$ binary, infix operators, at $n$ different levels of precedence: $E\rightarrow E\theta_{1}E\mid E\theta_{2}E\mid \cdot\cdot\cdot E\theta_{n}E\mid(E)\mid id$ ... of the tables for the two (ambiguous and unambiguous) grammars compare? What does that comparison tell you about the use of ambiguous expression grammars?
5
The following grammar is proposed to remove the "danglingelse ambiguity" discussed in Section $4.3.2$: $stmt\rightarrow if\: expr\: then\: stmt\mid matchedstmt$ $matchedstmt \rightarrow if \:expr \:then \:matchedstmt\: else\: stmt\mid other$ Show that this grammar is still ambiguous.
1 vote
6
Repeat Question $4.2.1$ for each of the following grammars and strings: $S\rightarrow 0S1\mid 01$ with string $000111$. $S\rightarrow +SS\mid \ast SS\mid a$ with string $+\ast aaa$. $S\rightarrow S(S)S\mid \epsilon$ with string $(()())$ ... $bterm\:\rightarrow\:bterm\:and\:bfactor\mid bfactor$ $bfactor\:\rightarrow\:not\:bfactor\mid (bexpr)\mid true\mid false$
7
Consider the context-free grammar:$S\rightarrow SS + \mid SS {\ast} \mid a$and the string $aa + a{\ast}$. Give a leftmost derivation for the string. Give a rightmost derivation for the string. Give a parse tree for the string. Is the grammar ambiguous or unambiguous? Justify your answer. Describe the language generated by this grammar.
1 vote
8
Which of the grammars are ambiguous? $S\rightarrow 0S1 \mid 01$ $S\rightarrow +SS \mid -SS \mid a$ $S\rightarrow S(S)S \mid \epsilon$ $S\rightarrow aSbS \mid bSaS \mid \epsilon$ $S\rightarrow a \mid S+S \mid SS \mid S^{\ast} \mid (S)$
9
Why is ambiguity in regular language is decidable and not decidable in CFL ? Can you give Example?
10
Give a context-free grammar that generates the language $A=\{a^{i}b^{j}c^{k}\mid i=j$ $\text{or}$ $j=k$ $\text{where}$ $i,j,k\geq 0\}.$ Is your grammar ambiguous$?$ Why or why not$?$
11
Prove the following result. Let $G = (V, T, S, P )$ be a context-free grammar in which every $A ∈ V$ occurs on the left side of at most one production. Then $G$ is unambiguous.
12
Is the string $aabbababb$ in the language generated by the grammar $S → aSS|b$? Show that the grammar with productions $S\rightarrow aAb|\lambda,$ $A\rightarrow aAb|\lambda$ is unambiguous.
13
Show that the grammar with productions $S\rightarrow aAB,$ $A\rightarrow bBb,$ $B\rightarrow A|\lambda.$ is unambiguous.
14
Show that the grammar with productions $S\rightarrow SS,$ $S\rightarrow \lambda,$ $S\rightarrow aSb,$ $S\rightarrow bSa.$ is ambiguous.
15
Show that the grammar $S\rightarrow aSb|SS|\lambda$ is ambiguous, but that the language denoted by it is not.
16
Show that the following grammar is ambiguous. $S\rightarrow aSbS|bSaS|\lambda$
17
Is it possible for a regular grammar to be ambiguous?
18
Construct an unambiguous grammar equivalent to the grammar in Exercise 6.
19
Show that the following grammar is ambiguous. $S\rightarrow AB|aaB,$ $A\rightarrow a|Aa,$ $B\rightarrow b.$
20
Show that every s-grammar is unambiguous.
21
Why is Regular grammar obtained from DFA always unambiguous? Why Regular grammar obtained from NFA may or may not be ambiguous?
22
Consider the following grammar which of the following is/are ambiguous? (i) S → y | SxS (ii) S → E | ExS and E → y (iii) S → Sxy | y
23
Which of the following statements is/are TRUE ? (i) The grammar S → SS | a is ambiguous (where S is the start symbol). (ii) The grammar S → 0S1 | 01S | e is ambiguous (the special symbol e represents the empty string and S is the start symbol). (iii) The grammar (where S is the ... (iii) are TRUE (D) All of (i), (ii) and (iii) are TRUE Sure shot (i) and (ii) are true i want third one in brief
24
Hi mates, Show that it is ambiguous grammar TIA S->aAB/bBA A->bS/a B->aS/b
1 vote
25
Which of the following statements is/are TRUE? The grammar $S \rightarrow SS \mid a$ is ambiguous. (Where $S$ is the start symbol) The grammar $S \rightarrow 0S1 \mid 01S \mid \epsilon$ is ambiguous. (The special symbol $\epsilon$ represents the empty string) (Where $S$ is the start symbol) The ... are TRUE. Only (a) and (c) are TRUE. Only (b) and (c) are TRUE. All of (a), (b) and (c) are TRUE.
26
Ques. S --> Aa/bAc/dc A --> d Isn't this grammar Ambiguous? If First(S) has more than one production giving the same first value, isn't it ambiguous?
27
As given that 1st is not regular and 2nd is regular as 1st not form AP but 2nd form.but if in 2nd we fix value of m and n same then it will work as 1st(not regular) so 2nd also should not be regular.as i know if we fix m or n value as any constant it will be AP but what if same???