This lecture demonstrates how to construct Non-Deterministic Finite Automata (NFA) for three string length constraints over the alphabet {A, B}: (1) strings with length exactly two, requiring two transitions from initial to final state; (2) strings with length at most two, where the initial state is also a final state to accept empty strings and single-symbol strings; (3) strings with length at least two, requiring an intermediate state before reaching the final state with self-loops to accept longer strings. The key principle is that NFAs only need to show acceptance paths, while rejection paths are implicitly handled.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Problems on NFA (Set 2)Added:
Hello everyone. Welcome to Nesso Academy. We are learning theory of computation and in the previous lecture we have solved four important problems on NFA construction. And today in this lecture, that is problems on NFA set two, we are going to solve few more remaining questions on NFA construction based on the length of the string. So let's get started.
In this lecture we will solve total three problems on NFA construction. So let's read the very first problem.
Design an NFA that accepts all strings with length exactly two over the alphabet A, B.
Which means you are required to construct a non-deterministic finite automata that will accept all the strings made up of A's and B's such that the length of the string is exactly equal to two.
Now length exactly equal to two means that the number of symbols in the strings should be exactly equal to two.
Not less than two, not greater than two.
Now what are these two symbols in the strings?
As you can see our alphabet is A, B.
So these two symbols can be either A or B. So the first symbol can also be either A or B and the second symbol will also be either A or B. Let's start designing our NFA.
First we will have our initial state, which is Q0. On getting the first symbol, which can be either A or B, we will reach the state Q1.
And on getting the second symbol, which also can be either A or B, we will reach the final state, which is Q2. And now our string is having two symbols, that is why the string is getting accepted.
So this is the required NFA for this problem. Now if it was required to create the DFA for the same problem, then we need to add one more transition for the state Q2 for the symbols A and B.
That would depict the strings of length greater than two, which will lead to the dead state. But in case of NFA, we usually focus only on the acceptance path. The path which is not present in NFA will automatically lead to rejection of the string.
So, let's move towards the second question.
Design an NFA that accepts all the strings with length at most two over the alphabet A {comma} B.
That means you are required to construct an NFA that accepts all the strings made up of A's and B's such that the length of the string is at most two.
Now, length at most two means the number of symbols in the strings should be less than or equal to two.
The number of the symbols in the strings should not be greater than two. So, let's start designing our NFA.
First, we will have our initial state, which is Q0. And you can see Q0 is the final state also.
Why?
Because as per this question, the length of the string should be at most two.
So, the length of the string can be zero, length of the string can be one, and length of the string can be two.
If the length of the string is zero, that means there is no symbol in the string.
And here you can see if there is no symbol in the string, that will also be accepted because zero is also less than two.
If I get only one symbol from A or B, that will also be accepted because one is also less than two.
If I get one more symbol, either A or B, that will also be accepted because two is also less than equal to two.
But if I get one more symbol, that will be rejected, and we need not to show the rejection path in case of NFA. So, this is the complete, required, and valid NFA for this problem. Now, let's proceed to our last problem.
Design an NFA that accepts all the strings with length at least two over the alphabet a {comma} b.
Which means you are required to construct an NFA that will accept all the strings made up of a's and b's such that the length of the string is at least two.
Length at least two means that the number of symbols in the strings should be greater than equal to two. The number of symbols in the string should not be less than two. Let's start designing our NFA.
First, we will have our initial state, which is q0. If I get only one symbol, our string is not getting accepted. It is reaching an intermediate state, which is q1. But, if I get one more symbol, the number of symbols are two. That means our string will be accepted because as per the question, the number of symbols should be greater than or equal to two. So, if we get more symbols after getting the second symbol, that will also be accepted because number of symbols can be greater than two. So, we will simply create a self loop over the state q2 for the symbols a and b, which depict that there can be more than two symbols in the string, which will be accepted.
So, these were the three important problems based on NFA construction that required the knowledge of length of the string.
Now, before ending this lecture, I have one homework problem for you.
So, here is the homework problem. In this problem, you are required to select the correct NFA out of these four NFA that accepts all the strings over the alphabet 0,1 such that the third symbol from the right end of the string is zero.
So, solve this problem and once you find the correct option, do not forget to post it in the comment section. So, in this way we have completed our topic problems on NFA.
So, till now we have completed two major topics of theory of computation, the deterministic finite automata and the non-deterministic finite automata. From the next lecture onwards, we are going to start with one of the most important topics of TOC that is repeatedly asked in your examinations.
Conversion of NFA into DFA.
So, this was all from my side for this lecture. Thank you and I'll see you in the next lecture.
>> [music] [music]
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
Re: 🗣️📍theprophedu📍2026 GST 103 CLASS (E-EXAM REVISION)
theprophedu
636 views•2026-06-04
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29











