← RGPV CS-501-CBGS Theory of Computation December 2020 Solved Paper
Question
Construct NFA for the following grammar: S → Ab | ab, A → Ab | Bb, B → Ba | a.
Asked in: CS-501 | December 2020 | 4(b)
Answer
For a left-linear rule X→Yw, add a path from Y to X labelled w. For X→w, add a path from a fresh initial state I to X labelled w. The only final state is S. Here S→Ab gives A —b→ S; S→ab gives I —a→ H —b→ S using a fresh H; A→Ab gives A —b→ A; A→Bb gives B —b→ A; B→Ba gives B —a→ B; B→a gives I —a→ B. All unlisted transitions are empty. For example S⇒Ab⇒Bbb⇒abb corresponds to I —a→ B —b→ A —b→ S. The NFA recognizes ab or a⁺bᵏ for k≥2. Reversing the direction of the left-linear rules is essential.

← RGPV CS-501-CBGS Theory of Computation December 2020 Solved Paper
Discussion
Ask a question, share your thoughts or report an error.
Sign in to participate in the discussion.
Join the discussion