• edited by
22,678 views
80 80 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$

6 Answers

Best answer
117 117 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
24 24 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.
15 15 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]
0 0 votes
If you carefully decode the grammar you will get :

S-> Zaa I Waa where Z can be replaced while epsilon or Sa while W can be replaced by Sa only

Hence the minimum possible string is aa ie., two a's must be there.

So, Min DFA will have 3 states while a given DFA can have any number of states as they're not unique but Minimal DFA is unique hence only 3 states possible for it
Answer:
Position:
Show:

Related questions

88 88 votes
7 answers 7 answers
27.1k
27.1k views
Ishrat Jahan asked Nov 3, 2014
27,143 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$ ...
86 86 votes
6 answers 6 answers
21.4k
21.4k views
Ishrat Jahan asked Nov 3, 2014
21,401 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 starting ...
51 51 votes
6 answers 6 answers
12.9k
12.9k views
Ishrat Jahan asked Nov 3, 2014
12,883 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 of $L$ and $M$ respectively. Whic...
74 74 votes
7 answers 7 answers
27.1k
27.1k views
Ishrat Jahan asked Nov 3, 2014
27,126 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...