edited by
566 views
4 votes
4 votes

Consider the following grammar: $G$ $E \rightarrow E+E \mid E-E \mid E^*E \mid (E)\mid \text{id}$

The number of derivation trees for the string $\text{id} +\text{id} ^* \text{id} – \text{id}$ is:

  1. $5$
  2. $6$      
  3. $7$    
  4. $8$
edited by

2 Answers

1 votes
1 votes
E--> E+E | E-E |E*E| (E)|id

id+id*id-id

1. E -> E+E

    E -> E + E * E

    E -> E + E * E - E

       -> id + id * id - id

2. E -> E+E

    E -> E + E - E

    E -> E + E * E - E

       -> id + id * id - id

3. E -> E*E

    E -> E + E * E

    E -> E + E * E - E

       -> id + id * id - id

    

4. E -> E - E

    E -> E * E - E

    E -> E + E * E - E

       -> id + id * id - id

5. E -> E-E

    E -> E + E - E

    E -> E + E * E - E

       -> id + id * id - id
Answer:

Related questions

6 votes
6 votes
2 answers
1
Bikram asked Nov 26, 2016
1,226 views
Given a regular grammar $G_1$ and a context free grammar $G_2$, the problem of deciding if $L(G_1)$ is a proper subset of $L(G_2)$ is:DecidableUndecidable but semi-decida...
0 votes
0 votes
1 answer
2
Bikram asked Nov 26, 2016
314 views
$G1$ and $G2$ are regular grammars and the language generated by any grammar $G$ is represented by $L(G)$. In this case, $L(G1) \cap L(G2) = \phi$ is a/an:Decidable prob...
0 votes
0 votes
1 answer
3
Bikram asked Nov 26, 2016
223 views
Recursive Enumerable Languages are NOT closed under :UnionIntersectionComplementHomomorphism
0 votes
0 votes
1 answer
4