CSS Computer Science (Optional) — Paper-I, Section-B, Topic VI. This page covers Section-B Compiler Construction questions extracted from the CSS Computer Science Paper-I past papers, 2016 through 2026 (54 question-patterns total: 44 subjective sub-parts and 10 MCQs). Content is grouped by year, most recent first.

Q1. Constructing a DFA for a Regular Expression

Appeared: 2026, Q7(a)

Construct a Deterministic Finite Automaton (DFA) for the regular expression (a|b)*abb.

Solution:

The language (a|b)*abb matches: any string of a's and b's, ending in exactly abb.

States: track how much of the suffix abb has been matched so far.

Transition table:

State on 'a' on 'b'
q0 (start) q1 q0
q1 q1 q2
q2 q1 q3 (accept)
q3 (accept) q1 q0

Reasoning for each transition:

Key reasoning points: this is the single most frequently reused DFA construction in compiler-theory exams (it appears, sometimes with aab/bab instead of abb, across many university and competitive-exam papers) precisely because it forces the student to handle overlapping suffixes correctly (e.g., realizing that from q2, an a doesn't send you back to q0 — it sends you to q1, since that a itself is progress toward a new abb). Getting the overlap transitions right is what separates a correct DFA from a plausible-looking wrong one.