Question:easy

Which of the following statements is/are true?

Show Hint

LL(1) needs the very next token alone to pick a production, so anything that makes two alternatives start the same way (a shared prefix, or infinite left recursion) breaks that requirement and must be removed first.
Updated On: Jul 22, 2026
  • LL(1) parser uses backtracking
  • For a grammar to be LL(1), it must be left-recursive
  • For a grammar to be LL(1), it must be left-factored
  • The LL(1) parsers are more powerful than the SLR parsers
Show Solution

The Correct Option is C

Solution and Explanation

Step 1: Test each statement against a tiny concrete grammar instead of quoting definitions.
Take the grammar $A \rightarrow aB \mid aC$ as a stand-in for two alternatives sharing a prefix, and $E \rightarrow E+T \mid T$ as a stand-in for left recursion.

Step 2: Backtracking, option (A).
An LL(1) parser looks at one token, say the current input is $a\ldots$, and for grammar $A \rightarrow aB \mid aC$ it genuinely cannot tell whether to expand to $aB$ or $aC$ from that single token; that ambiguity is exactly why this grammar is rejected as not LL(1), rather than being accepted and resolved by trial-and-error backtracking. A true LL(1) parser table lookup either finds a unique production or reports an error immediately; there is no retry step built into the method, so (A) is false.

Step 3: Left recursion, option (B).
Feed $E \rightarrow E+T \mid T$ to a top-down predictive parser: to expand $E$ it would first try the alternative $E+T$, which begins by needing to expand $E$ again, which tries $E+T$ again, forever, without reading a single input symbol. This infinite loop is precisely why every LL(1) grammar must have left recursion eliminated (rewritten into an equivalent right-recursive form) before use, so the claim that LL(1) grammars must be left-recursive is exactly backwards; they must NOT be left-recursive. (B) is false.

Step 4: Left factoring, option (C).
Return to $A \rightarrow aB \mid aC$: because both alternatives start with $a$, $\text{FIRST}(aB)$ and $\text{FIRST}(aC)$ overlap on $a$, so the LL(1) parsing table would need two different entries in the same cell $[A, a]$, which is not allowed in a deterministic table. Left-factoring rewrites this as $A \rightarrow aA'$, $A' \rightarrow B \mid C$, removing the clash. This shows left-factoring is a required step to reach an LL(1)-compatible form whenever alternatives share a prefix, confirming (C) is true.

Step 5: Power comparison with SLR, option (D).
Every grammar that an LL(1) top-down table can handle can equally be handled by an SLR(1) bottom-up parser (the SLR class strictly contains the LL(1) class), while there exist grammars that SLR(1) parses correctly but that fail the LL(1) prefix/lookahead conditions. So SLR parsers accept a strictly larger set of grammars, meaning it is SLR that is more powerful, not LL(1); (D) is false.

Step 6: Result.
$\[ \boxed{\text{Only (C) holds true}} \]$
Was this answer helpful?
0

Top Questions on Parsing


Questions Asked in GATE CS exam