Two derivation so it is ambiguous

Gammer is ambiguous. But above statement requires

Refer --> Option(A) for https://gateoverflow.in/711/gate2001-1-18

ping @kenzou

The Gateway to Computer Science Excellence

First time here? Checkout the FAQ!

x

+13 votes

- Remove left-recursion from the following grammar: $S \rightarrow Sa \mid Sb \mid a \mid b$
- Consider the following grammar:

$S \rightarrow aSbS\mid bSaS \mid ∊$

Construct all possible parse trees for the string abab. Is the grammar ambiguous?

+24 votes

Best answer

- $S \rightarrow aS'\mid bS'$

$S' \rightarrow aS' \mid bS' \mid \epsilon$

- $S \rightarrow aSbS \rightarrow abS \rightarrow abaSbS \rightarrow ababS \rightarrow abab$

$S \rightarrow aSbS \rightarrow abSaSbS \rightarrow abaSbS \rightarrow ababS \rightarrow abab$

The above two derivations corresponds to two different parse trees and hence the grammar is ambiguous.

0

Two derivation so it is ambiguous

Gammer is ambiguous. But above statement requires

Refer --> Option(A) for https://gateoverflow.in/711/gate2001-1-18

ping @kenzou

- All categories
- General Aptitude 1.6k
- Engineering Mathematics 7.3k
- Digital Logic 2.7k
- Programming & DS 4.9k
- Algorithms 4.2k
- Theory of Computation 5.4k
- Compiler Design 2.1k
- Databases 4k
- CO & Architecture 3.5k
- Computer Networks 4.2k
- Non GATE 1.4k
- Others 1.5k
- Admissions 570
- Exam Queries 566
- Tier 1 Placement Questions 23
- Job Queries 70
- Projects 18

48,720 questions

52,825 answers

183,476 comments

68,571 users