**Prerequisite:** Finite Automata Introduction

**Problem-1:**

Construction of a minimal NFA accepting a set of strings over {a, b} in which each string of the language ends with ‘ab’.

**Explanation:**

The desired language will be like:

L1 = {ab, abbab, abaab, ...........}

Here as we can see that each string of the above language ends with ‘ab’ but the below language is not accepted by this NFA because some of the string of below language does not end with ‘ab’.

L2 = {bba, abb, aaabbbb, .............}

The state transition diagram of the desired language will be like below:

In the above NFA, the initial state ‘X’ on getting ‘a’ as the input it either remains in the state of itself or transit to a state ‘Y’ and on getting ‘b’ as the input it remains in the state of itself. The state ‘Y’ on getting ‘b’ as the input it transmits to a final state ‘Z’.

**Problem-2:**

Construction of a minimal NFA accepting a set of strings over {a, b} in which each string of the language is not ending with ‘ab’.

**Explanation:** The desired language will be like:

L1 = {bba, abb, aaabbbb, .............}

Here as we can see that each string of the above language is not ending with ‘ab’ but the below language is not accepted by this NFA because some of the string of below language is ending with ‘ab’.

L2 = {ab, abab, ababaab..............}

The state transition diagram of the desired language will be like below:

In the above NFA, the initial state ‘X’ on getting ‘a’ as the input it remains in the state of itself and on getting ‘b’ as the input it transmits to a state ‘Y’. The state ‘Y’ on getting ‘b’ as the input it either remains in the state of itself or transmits to a final state ‘Z’. The final state ‘Z’ on getting ‘a’ as the input it remains in the state of itself.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Construction of the machines that produce 'A', 'B', or 'C' if input ends with '1', '0', or nothing
- Build a DFA to accept Binary strings that starts or ends with "01"
- Moore and Mealy machines to count number of substring ‘ab’
- Construction of finite machines to prints ‘1’ as the output for every occurrence of ‘a’ as a substring
- DFA machines accepting odd number of 0’s or/and even number of 1’s
- Mealy and Moore Machines in TOC
- DFA for accepting the language L = { a
^{n}b^{m}| n+m=even } - DFA for accepting the language L = {a
^{n}b^{m}| n+m=odd} - Moore and Mealy machines to produce 'A', 'B', 'C' depends on inputs that end with ’10’ or with ’11’ else other
- NPDA for accepting the language L = {a
^{m}b^{n}c^{n}| m,n ≥ 1} - NPDA for accepting the language L = {a
^{n}b^{(2n)}| n>=1} U {a^{n}b^{n}| n>=1} - NPDA for accepting the language L = {a
^{n}b^{m}c^{n}| m,n>=1} - NPDA for accepting the language L = {a
^{i}b^{j}c^{k}d^{l}| i==k or j==l,i>=1,j>=1} - NPDA for accepting the language L = {a
^{m}b^{(2m+1)}| m ≥ 1} - NPDA for accepting the language L = {a
^{m}b^{(m+n)}c^{n}| m,n ≥ 1} - NPDA for accepting the language L = {a
^{n}b^{m}| n,m ≥ 1 and n ≠ m} - NPDA for accepting the language L = {a
^{(m+n)}b^{m}c^{n}| m,n ≥ 1} - NPDA for accepting the language L = {a
^{m}b^{(2m)}| m>=1} - NPDA for accepting the language L = {a
^{m}b^{n}c^{p}d^{q}| m+n=p+q ; m,n,p,q>=1} - NPDA for accepting the language L = {a
^{n}b^{n}| n>=1}

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.