Let be a context-free grammar in Chomsky Normal Form with and containing 10 variable symbols including the start symbol . The string is derivable from . The number of steps (application of rules) in the derivation is ______.
GATE 2024 CS1 Q.59: solution and answer
Answer and solution
ANSWER
The derivation takes 179 steps.
Official answer: 179Source: Official answer key, GATE 2024 CS1 (IISc Bengaluru)
In Chomsky Normal Form every production is either (two variables) or (one terminal).
The string has length .
Each rule adds one terminal and no other symbol is ever turned into a terminal. So exactly rules of this kind are used, one for each terminal of .
Each rule replaces one symbol by two, so it raises the length of the sentential form by exactly . Rules leave the length unchanged. We start from the single symbol (length ) and end at length , so exactly rules of the form are used.
Total number of steps .
The count depends only on . The number of variables (10) and the particular derivation do not change it.
KEY IDEA
In a CNF grammar, deriving a string of length always takes exactly rules and rules , so steps in all.
WATCH OUT FOR
Counting only the binary rules, or only the terminal rules. Another slip is trying to use the number of variables (10) or the shape , neither of which affects the count.
From the GATE 2024 CS1 paper. Every question of this paper · Download the full paper · All 9 CFG & PDA questions, with notes
More CFG & PDA questions
- GATE 2023 CS Q.39 · MCQ · 2 marksConsider the context-free grammar G below S → aSb X X → aX Xb a b where S and X are non-terminals, and a and…
- GATE 2023 CS Q.40 · MCQ · 2 marksConsider the pushdown automaton (PDA) P below, which runs on the input alphabet a, b, has stack alphabet, A…
- GATE 2026 CS1 Q.25 · MSQ · 1 markConsider the following grammar where S is the start symbol, and a and b are terminal symbols.
- GATE 2026 CS1 Q.52 · MSQ · 2 marksConsider the following context-free grammar G. S → abaABAbba A → aaBBAb bBabaa B → aBb ab In the above…
