**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 CS Theory concepts for SDE interviews with the **CS Theory Course** at a student-friendly price and become industry ready.