GATE Computer ScienceVery hardGATE CS (PYQ pattern)
The grammar S → aSBC | aBC; CB → BC; aB → ab; bB → bb; bC → bc; cC → cc generates { aⁿbⁿcⁿ : n ≥ 1 }. How many derivation steps does EVERY derivation of aaabbbccc take?
- A. 9
- B. 15
- C. 12
- D. 11
Correct answer: C. 12
Any derivation uses S → aSBC twice and S → aBC once (3 steps), giving aaaBCBCBC. Each CB → BC removes exactly one C-before-B inversion, and BCBCBC has 2 + 1 = 3 such pairs (3 steps). Then each of the 6 variables is turned into a terminal by exactly one rule (6 steps). Total 12.
More Theory of Computation questions
- Which of the following productions cannot appear in a context-sensitive (non-contracting) grammar?
- A grammar has productions S → aS | bA | ε; A → aA | b. Which is the most restricted class of the Chomsky hierarchy that the grammar…
- Which of the following statements are correct? I. Every context-free language over a one-letter alphabet is regular. II. { a^(2ⁿ) : n ≥ 0…
- Let A = { ⟨M⟩ : the Turing machine M accepts at most one string }. Which statement is correct?
- Which of the following statements about the Post Correspondence Problem (PCP) are correct? I. PCP restricted to a one-letter alphabet is…
- To prove by the pumping lemma for context-free languages that L = { w w : w ∈ {a, b} } is not context-free, which string (p is the pumping…