GATE CSE 2021 Set 1 Q15: SLR(1) grammars, ambiguity and cubic-time CFG parsing
- Compiler Design
- 1 mark
- MCQ
- −1/3 if wrong
Question
Consider the following statements.
: Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1).
: For any context-free grammar, there is a parser that takes at most time to parse a string of length .
Which one of the following options is correct?
Try it: multiple choice: exactly one correct option
Show answer and explanation
Answer: C (official GATE 2021 final answer key)
Concept used: Deterministic parsers never accept ambiguous grammars; general CFG parsing (CYK, Earley) runs in cubic time.
First step: Recall that some unambiguous grammars are LALR(1) or LR(1) but not SLR(1), and CYK parses any CFG in .
Full step-by-step solution
Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.
Share this question
Source: official GATE 2021 Set 1 CS question paper and final answer key, organised by IIT Bombay. Question paper · Answer key
More Compiler Design PYQs
- 2026 Session 1 · Q27Classify errors in three C string declarations
- 2026 Session 1 · Q28True statements about LL(1) parsing
- 2026 Session 1 · Q42Redundant (common) subexpressions in blocks B4 and B5 of a CFG
- 2026 Session 1 · Q53Compare two SDDs for type declarations
- 2026 Session 2 · Q35Count tokens produced by a lexer for a given string
- 2026 Session 2 · Q41Shift-reduce conflicts in the LR(0) table of a grammar