retagged by
320 views
0 votes
0 votes

Consider the grammar:

  • $S\rightarrow$ $PQ | SQ | PS$
  • $P\rightarrow k$
  • $Q\rightarrow m$


To get a set of $n$ terminals, the number of productions to be used are ______.

  1.     $n^{2}$
  2.     $n + 1$
  3.     $2n - 1$
  4.     $2n$
retagged by

1 Answer

Best answer
1 votes
1 votes
By induction, to get a string of length 2 , we need 3 productions

S-->PQ , P->k , Q->m

to get a string of length 3 , we need 5 productions

S --> SQ, S -->  PQ, P -->  k, P -->  m
S => SQ => PQQ => kQQ => kmQ => kmm

Thus we need 2n − 1 productions to get string of length n.

Hence  option C is correct .
selected by
Answer:

Related questions

0 votes
0 votes
1 answer
1
Bikram asked Feb 9, 2017
228 views
The grammar having no Epsilon$\left ( \epsilon \right )$ transition or two adjacent nonterminals in the right side of any production is ?$LL$$\left ( 1 \right )$ grammarO...
2 votes
2 votes
1 answer
3