GATE Computer ScienceHardGATE CS (PYQ pattern)
For G: S → A A; A → a A | b | ε, which statements are true? I. FOLLOW(A) = {a, b, $}. II. G is LL(1). III. G is ambiguous. IV. G is LR(1).
- A. I, II and IV only
- B. I and IV only
- C. I and III only
- D. III only
Correct answer: C. I and III only
FOLLOW(A) gets FIRST(A) − ε = {a, b} from S → A A and FOLLOW(S) = {$} because the second A ends S: I true. The string a has two trees (first A = a, second ε; or first ε, second a), so G is ambiguous (III true) and therefore neither LL(1) (M[A, a] holds A → a A and A → ε) nor LR(1).
More Compiler Design questions
- A DFA reads a binary number most-significant bit first (leading zeros allowed; the empty string counts as 0). How many states does the…
- The grammar S → S a b | S c | A S | x; A → A d | S y | z is transformed by the standard algorithm that removes (indirect and immediate)…
- For the code 1: i = 0; 2: s = 0; 3: L1: if i >= n goto L4; 4: t = a + i; 5: if t > m goto L2; 6: s = s + t; 7: goto L3; 8: L2: a = a - 1…
- For G: S → a B | a C d; B → b | ε; C → b c, which statements are true? I. G is LL(2). II. G is LL(3). III. G is LR(0). IV. G is SLR(1).
- Construct the LL(1) table of S → A B c | B d; A → a A | ε; B → b B | A. Which option lists exactly the multiply-defined cells?
- An ε-NFA over {a, b} has states 0–4, start state 0 and accepting state 3, with moves δ(0, a) = {1}, δ(1, b) = {2}, δ(2, a) = {0, 3}, δ(3…