- $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$