Question
Consider a context-free grammar with the following 3 rules.
Let . Let denote the number of times occur in , respectively. Which of the following statements is/are TRUE?
Official answer and solution
- Official answer
- B and C
- From
- Official GATE 2024 answer key
Solution
Count how many times each production rule is applied in any derivation of .
In any derivation starting from , suppose the rule is applied times, and the rule is applied times:
- Each application of increases the number of nonterminal instances by , while keeps the number of instances unchanged. Starting with instance of , the total number of instances that eventually terminate via is .
- Counting terminal occurrences in :
- (C) is TRUE (and (D) is FALSE).
- .
- Checking (A): When (e.g., , where ), , so is FALSE.
- Checking (B): Since and , we always have , so (B) is TRUE.
Options (B), (C)
Forgetting the base case (where ) and mistakenly selecting (A).
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2024 Computer Science and Information Technology - Set 2 (CS2)
- 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.