GATE CS 2024 Set 1 — Question 59

NAT+2 / -0MediumParse Trees & DerivationsContext-Free LanguagesTheory of ComputationChomsky Normal Form

Theory of Computation → Context-Free Languages → Chomsky Normal Form

Last updated

Question

Let G=(V,Σ,S,P)G = (V, \Sigma, S, P) be a context-free grammar in Chomsky Normal Form with Σ={a,b,c}\Sigma = \{a, b, c\} and VV containing 10 variable symbols including the start symbol SS. The string w=a30b30c30w = a^{30}b^{30}c^{30} is derivable from SS. The number of steps (application of rules) in the derivation SwS \rightarrow^* w is _________

Correct answer

179 to 179

Solution

In a Context-Free Grammar (CFG) in Chomsky Normal Form (CNF), every production is of the form A → BC or AaA \rightarrow a, where A,B,CVA, B, C \in V and aΣa \in \Sigma.
To derive a string of length nn:
1.We need n1n-1 applications of rules of the form A → BC to generate a sentential form with nn variables. Starting from the start symbol SS (1 variable), each such rule application increases the number of variables by exactly 1. Thus, to reach nn variables, we need n1n-1 steps.
2.We need nn applications of rules of the form AaA \rightarrow a to replace each of the nn variables with a terminal symbol from Σ\Sigma.
Total number of steps = (n1)+n=2n1(n-1) + n = 2n - 1.
Given the string w=a30b30c30w = a^{30}b^{30}c^{30}, its length n=30+30+30=90n = 30 + 30 + 30 = 90.
Number of steps = 2(90)1=1801=1792(90) - 1 = 180 - 1 = 179.
Note: The total number of variables in VV (which is 10) is irrelevant to the number of steps in the derivation of a specific string.

More questions on Context-Free Languages

Practice GATE CS PYQs with adaptive difficulty

Timed practice, skill tracking, and AI explanations — free to start.

Start practicing free