Question
Consider the following context-free grammar .
In the above grammar, is the start symbol, and are terminal symbols, and and are non-terminal symbols.
Let be the language generated by the grammar . For a string , let be the number of 's in and be the number of 's in .
Which of the following statements is/are true?
Official answer and solution
- Official answer
- B and D
- From
- Official GATE 2026 answer key
Solution
Count the number of terminal 's and 's introduced by each production rule in .
Let denote the number of terminal 's and 's directly introduced by each production rule:
- : , which satisfies .
- : , which satisfies .
- : , which satisfies .
- and : , which satisfies .
Since every production rule in introduces at least as many 's as 's () and at most twice as many 's as 's (), summing over all derivation steps of any string yields:
Thus (B) and (D) are true, while (A) and (C) are false.
Options (B), (D)
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2026 Computer Science and Information Technology - Session 1 (CS1)
- Question
- 52 of 65
- 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.