edited by
3,603 views
2 votes
2 votes

Consider the grammar:
S->aSbS/ bSaS/ ε,
The smallest string for which the grammar has two derivation trees:

  1. abab
  2. aabb
  3. bbaa
  4. aaabbb


and how?

edited by

2 Answers

Best answer
4 votes
4 votes

Option A
The smallest string that can be derived is abab

S $\rightarrow$ aSbS $\rightarrow$ a[bSaS]bS , now substitute ε in place of S, we will get 'abab'
S $\rightarrow$ aSbS $\rightarrow$ a[ε]bS $\rightarrow$ ab[aSbS] , now substitue ε in place of S, we will get 'abab'

selected by
0 votes
0 votes
(A)abab       as in second level of derivation tree we have 2 choices to connect bSa either on middle S or on rightmost S

Related questions

0 votes
0 votes
0 answers
1
2 votes
2 votes
0 answers
2
0 votes
0 votes
0 answers
3