retagged by
20,406 views
34 votes
34 votes

$$S \to aSa \mid bSb\mid a\mid b$$
The language generated by the above grammar over the alphabet $\{a,b\}$ is the set of:

  1. all palindromes
  2. all odd length palindromes
  3. strings that begin and end with the same symbol
  4. all even length palindromes
retagged by

7 Answers

1 votes
1 votes

option A is wrong as the given grammar can not generate the string like aa, bb, aaaa  

option D is wrong because it also covered string like  aa, bb which can not be generated by the given grammar

option C and option B are correct but option C is already covered in option B so we can neglect option C 

option B is the correct answer as it can generate a,b , bab, aaa, ababa ... etc

0 votes
0 votes
option B all odd length palindromes is the correct

and c is false as aaba can not be generated from it
0 votes
0 votes

From the grammar, we can easily infer that it generates all the palindromes of odd length, for ex: strings {aba, bab, aaa, bbb, ….}

Answer:

Related questions

20 votes
20 votes
5 answers
2
Kathleen asked Sep 22, 2014
8,534 views
In which one of the following page replacement policies, Belady's anomaly may occur?FIFOOptimalLRUMRU
33 votes
33 votes
5 answers
4