# Minimal DFA Construction, Pumping Lemma, CFGs & Pushdown Automata
Exam: GATE Computer Science & Information Technology (GATE CS)
Subject: Theory of Computation
Canonical URL: https://gateandnet.com/exams/gate-cs/theory-of-computation/dfa-minimization-pumping-lemma-and-pda

> Exact state counts for common minimal DFAs, Myhill-Nerode theorem, Pumping Lemma traps, Chomsky Normal Form derivation steps (2n - 1), and DPDA vs NPDA expressive power.

## 1. High-Speed Minimal DFA State Count Patterns

Over binary alphabet $\Sigma = \{0, 1\}$ (or $\{a, b\}$):
1. **Strings of length divisible by $k$:** **$k$ states**
2. **Binary numbers divisible by $k$:** **$k$ states** if $k$ is odd; reduced if $k = 2^m$ ($m+1$ states when leading zeros allowed)
3. **Strings containing substring $w$ of length $k$:** **$k + 1$ states**
4. **Strings starting with $a$ and ending with $b$:** **4 states**
5. **Strings whose $k$-th symbol from the right is $1$:** **$2^k$ states** in minimal DFA (only $k+1$ in NFA!)

## 2. Expressive Power of Automata Across the Chomsky Hierarchy

| Language Class | Grammar Type | Automaton Model | Deterministic == Non-Deterministic? |
| :--- | :--- | :--- | :--- |
| **Regular (Type 3)** | Right/Left-Linear | Finite Automaton | **YES:** $\text{DFA} \equiv \text{NFA} \equiv \epsilon\text{-NFA}$ |
| **DCFL $\subsetneq$ CFL (Type 2)** | Context-Free ($A \to \alpha$) | Pushdown Automaton | **NO!** $\text{DPDA} \subsetneq \text{NPDA}$ |
| **CSL (Type 1)** | Context-Sensitive ($|\alpha| \le |\beta|$) | Linear Bounded Automaton | Open problem ($\text{NSPACE}(n) = \text{DSPACE}(n)$?) |
| **RE (Type 0)** | Unrestricted | Turing Machine | **YES:** $\text{DTM} \equiv \text{NTM} \equiv k\text{-tape TM}$ |

> [!TRAP]
> **Classic DPDA vs NPDA Examples:**
> - $L_1 = \{ w c w^R \mid w \in \{a,b\}^* \}$ is a **DCFL** (center marker $c$ tells DPDA when to switch from push to pop).
> - $L_2 = \{ w w^R \mid w \in \{a,b\}^* \}$ is a **CFL but NOT DCFL** (requires NPDA to guess the midpoint!).
> - $L_3 = \{ w w \mid w \in \{a,b\}^* \}$ and $\{a^n b^n c^n \mid n \ge 0\}$ are **NOT Context-Free** (CSL)!

## Solved Practice Questions & PYQs

### [GATE CS TOC | MCQ]
What is the number of states in the **minimal DFA** over $\Sigma = \{0, 1\}$ that accepts all binary strings whose **3rd symbol from the right end** is `1`?
**Correct Answer:** C
**Solution:** To remember the last $k$ symbols seen so far deterministically, a minimal DFA requires **$2^k$ states** (one per $k$-bit suffix). For $k = 3$, minimal DFA states $= 2^3 = \mathbf{8}$ (whereas an NFA needs only $k + 1 = 4$ states).

### [GATE CS TOC | MCQ]
Which of the following languages over $\Sigma = \{a, b, c\}$ is accepted by a **Non-Deterministic PDA (NPDA)**, NOT by any **Deterministic PDA (DPDA)**?
**Correct Answer:** C
**Solution:** $\{a^n b^n\}$ and $\{w c w^R\}$ are **DCFLs** (accepted by DPDA). $\{a^n b^n c^n\}$ is **not even Context-Free** (CSL). Even-length palindromes $\{w w^R\}$ have no center marker, so the PDA must non-deterministically guess the midpoint $\implies$ **CFL $\setminus$ DCFL**!

### [UGC NET / GATE TOC | MCQ]
If a Context-Free Grammar $G$ is in **Chomsky Normal Form (CNF)**, how many derivation steps are required to derive a terminal string $w$ of length $|w| = 12$?
**Correct Answer:** B
**Solution:** In CNF ($A \to BC$ or $A \to a$), generating $n$ variables takes $n - 1$ binary expansions and replacing them with $n$ terminals takes $n$ steps: total steps $= 2n - 1 = 2(12) - 1 = \mathbf{23}$.
