Question
Which of the following languages is generated by the given grammar?
Official answer and solution
- Official answer
- D
- From
- Official GATE 2016 answer key
Solution
Trace the language produced by the recursive context-free grammar.
Given the grammar rules with start symbol :
At each derivation step, can prepend either the terminal symbol or , or terminate by producing :
By induction, any arbitrary finite sequence of 's and 's can be generated by applying the corresponding production rules followed by . Therefore, the grammar generates the set of all binary strings over , which is (or .
D
Assuming the grammar requires 's before 's, confusing with .
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2016 Computer Science and Information Technology (CS) Session 1
- Question
- 26 of 65, printed as CS Q.16
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.