GATE CS 2023 | Question 19
Compiler Design › Basics & Lexical · MCQ · 1 mark · Answer: C
- Question 19Compiler Designmcq1 markGiven letter -> [A-Za-z], digit -> [0-9], id -> letter (letter | digit)*, which NFA with epsilon-transitions (shown as options A-D) accepts the set of valid identifiers?

- A.(A)
- B.(B)
- C.(C)✓
- D.(D)
Answer: C
Solution
Answer: (C) A valid identifier matchesletter (letter | digit)*. The correct NFA reads exactly one letter to reach the accepting (double-circle) state, then has an epsilon-structured loop that consumes any number of further letters or digits and returns to the accepting state. Option (C) is the automaton whose epsilon-transitions correctly implement the(letter | digit)*loop after the first letter. The others either accept the empty string or wire the epsilon-loop so it does not faithfully realize(letter | digit)*. - A.
More GATE PYQ on Basics & Lexical
All GATE CS Compiler Design PYQ →Attempt GATE CS 2023 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →