Question
Consider the context-free grammar below
where and are non-terminals, and and are terminal symbols. The starting non-terminal is .
Which one of the following statements is CORRECT?
Official answer and solution
- Official answer
- B
- From
- Official GATE 2023 answer key
Solution
Analyze the strings generated by non-terminal and their embedding into .
-
Non-terminal has productions:
This grammar generates any string consisting of one or more characters from where all 's appear before all 's, i.e., .
-
Non-terminal has productions:
Applying times () wraps the string generated by with leading 's and trailing 's:
Because absorbing additional 's on the left and 's on the right of yields precisely the same set , the language generated is simply .
-
Since is a regular expression, the language is regular.
Option (B)
Concluding the language is non-regular due to the production without realizing already generates all unbalanced combinations.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2023 Computer Science and Information Technology (CS)
- Question
- 39 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.