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 S→∗wS \rightarrow^* w is _________

Official answer and solution
Official answer
179
From
Official GATE 2024 answer key

Solution

Use the property that deriving any string of length n≥1n \ge 1 in a Chomsky Normal Form (CNF) grammar requires 2n−12n - 1 production steps.

In Chomsky Normal Form (CNF), every production is either of the form A→BCA \rightarrow BC (which increases the number of variables in the sentential form by 11) or A→aA \rightarrow a (which replaces 11 variable with 11 terminal). To derive a string ww of length n=∣w∣≥1n = |w| \ge 1:

  • Exactly n−1n - 1 steps of type A→BCA \rightarrow BC are used to expand SS into nn variables.
  • Exactly nn steps of type A→aA \rightarrow a are used to convert those nn variables into terminals.

Here w=a30b30c30w = a^{30}b^{30}c^{30} has length n=30+30+30=90n = 30 + 30 + 30 = 90. Therefore, the total number of derivation steps is:

2n−1=2(90)−1=1792n - 1 = 2(90) - 1 = 179
Final answer

179

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 1 (CS1)
Question
59 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.