Consider a grammar where the only rules are and . What is the minimum number of applications of the recursive rule required to generate a string of length 4?
B
Step-by-Step Solution
Key idea: This is a minimum calculation question based on the length contribution of recursive rules.
Step 1: Analyze the base rule . It adds 0 to the length of the string.
Step 2: Analyze the recursive rule . Each application adds exactly 2 terminals ( and ) to the string.
Step 3: We want a final string of length 4.
Step 4: Since the base rule adds 0, the entire length of 4 must come from the recursive rule.
Step 5: Divide the target length by the length added per recursive step: .
Step 6: The minimum number of applications of the recursive rule is 2.
Answer: 2.