GATE Computer ScienceVery hardGATE CSE
Grammar: S → a S b | S S | ε. How many distinct strings of length exactly 10 belong to the language it generates?
- A. 252
- B. 32
- C. 42
- D. 52
Correct answer: C. 42
The language is the set of balanced a/b strings (a = opening, b = closing); length 10 has C₅ = 42 of them, whereas C(10,5) = 252 counts all strings with equal numbers.
More Compiler Design questions
- Backpatching with no fall-through optimisation, numbering from 100, translates while (a < b && c < d || e < f) { if (x < y) p = 1; else q…
- For the augmented grammar S′ → S; S → a S a | b S b | c, how many states does the canonical LR(1) automaton have, and how many does the…
- For the grammar G: S → A b | B c; A → a A | ε; B → a B | ε, the LL(1) predictive table is built. Which statement is correct?
- For G: S → a A | b B; A → c A d | ε; B → c B d d | ε, which statements are true? I. G is LL(1). II. G is LR(0). III. The canonical LR(1)…
- A scanner has two token rules, R1 = a b and R2 = b c. It always takes the longest prefix matching some rule and never backtracks over a…
- Register allocation by graph colouring is done on the loop 1: L1: v1 = v4 + 1; 2: v2 = v5 + 1; 3: v3 = v1 + 1; 4: v4 = v2 + 1; 5: v5 = v3…