edited by
12,435 views
64 votes
64 votes

Consider the regular grammar:

  • $S \rightarrow Xa \mid Ya$
  • $X \rightarrow Za$
  • $Z \rightarrow Sa \mid \epsilon$
  • $Y \rightarrow Wa$
  • $W \rightarrow Sa$

where $S$ is the starting symbol, the set of terminals is $\{a\}$ and the set of non-terminals is $\{S, W, X, Y, Z\}$.
We wish to construct a deterministic finite automaton (DFA) to recognize the same language. What is the minimum number of states required for the DFA?

  1. $2$
  2. $3$
  3. $4$
  4. $5$
edited by

4 Answers

Best answer
95 votes
95 votes
  • $S \rightarrow Xa \mid Ya$
  • $X \rightarrow Za$
  • $Z \rightarrow Sa \mid \epsilon$
  • $Y \rightarrow Wa$
  • $W \rightarrow Sa$

This is left linear grammar having language L. Convert it into right linear using following rule:

  • $V_i \to V_jw \qquad \text{Reverses to}\qquad V_i \to w^RV_j$
  • $V_i \to w \qquad \quad\text{Reverses to}\qquad V_i \to w^R$

If the left linear grammar produced language $L$ then the resulting right linear grammar produces $L^R.$

  • $S \rightarrow aX \mid aY$
  • $X \rightarrow aZ$
  • $Z \rightarrow aS \mid \epsilon$
  • $Y \rightarrow aW$
  • $W \rightarrow aS$

is right linear grammar having language $\mathbf{L^R}$.  

Having NFA

Having DFA for language $\mathbf{L^R}$

DFA for language L ( reversal)

$\mathbf{L = \{ w : n_a(w) \ mod \ 3 =2 ,\text{ w belongs to } \{a,b\}^* \}}$  same as Omesh Pandita answered.

Having 3 states.

Correct Answer: $B$

edited by
22 votes
22 votes
(B) 3

The string generated by the language is the set of strings with $a$'s such that number of $a$ mod 3 is 2.

So the number of states required should be 3 to maintain the count of number of $a$'s mod 3.
10 votes
10 votes
Minimize the grammer as much as you can. (Putting the values of lower productions to upper one).

Then finally we get

S→aa∣Saaa

Now we can draw dfa with 3 states.

[it may be an informal approach but we get answer fast]
Answer:

Related questions

16.6k
views
4 answers
54 votes
Ishrat Jahan asked Nov 3, 2014
16,613 views
Consider the non-deterministic finite automaton (NFA) shown in the figure.State $X$ is the starting state of the automaton. Let the language accepted by the NFA with $Y$ as ... is TRUE?$L1 = L2$L1 \subset L2$L2 \subset L1$None of the above
12.8k
views
5 answers
66 votes
Ishrat Jahan asked Nov 3, 2014
12,770 views
Let $P$ be a non-deterministic push-down automaton (NPDA) with exactly one state, $q$, and exactly one symbol, $Z$, in its stack alphabet. State $q$ is both the ... are necessarily $Σ^*$.Neither $L(P)$ nor $N(P)$ are necessarily $Σ^*$
8.0k
views
4 answers
40 votes
Ishrat Jahan asked Nov 3, 2014
7,983 views
Let $L$ be a regular language and $M$ be a context-free language, both over the alphabet $Σ$. Let $L^c$ and $M^c$ denote the complements ... context-free.It is necessarily context-free.It is necessarily non-regular.None of the above
15.4k
views
7 answers
49 votes
Ishrat Jahan asked Nov 3, 2014
15,441 views
Consider a simple graph with unit edge costs. Each node in the graph represents a router. Each node maintains a routing table indicating the next hop router to be used to relay a ... $>100$ but finite$\infty$3$>3$ and $\leq 100$