Let πΊ = (π, Ξ£, π, π) be a context-free grammar in Chomsky Normal Form withβ¦
2024
Let πΊ = (π, Ξ£, π, π) be a context-free grammar in Chomsky Normal Form with Ξ£ = {π, π, π} and π containing 10 variable symbols including the start symbol π. The string π€ = π30π30π30 is derivable from π. The number of steps (application of rules) in the derivation π ββ π€ is _________
Attempted by 38 students.
Show answer & explanation
Correct answer: 179
Key insight: in a Chomsky Normal Form derivation each application of a rule either replaces one variable by two variables (A β BC) or replaces one variable by a terminal (A β a).
Let n be the length of the derived string. Each terminal in the final string requires exactly one application of a rule of the form A β a, so the number of terminal-rule applications is n.
Let x be the number of binary-rule applications A β BC. Starting from one variable (the start symbol), each binary rule increases the current number of variables by 1, and each terminal rule decreases it by 1. To end with zero variables, we need x β n = β1, so x = n β 1.
Total number of rule applications = (number of binary rules) + (number of terminal rules) = (n β 1) + n = 2n β 1.
Apply this to the given string of length 30 + 30 + 30 = 90: total steps = 2Β·90 β 1 = 179.
A video solution is available for this question β log in and enroll to watch it.