Skip to content
Related Articles

Related Articles

Construct DFA with Σ = {0, 1} and Accept All String of Length at Least 2

Improve Article
Save Article
  • Last Updated : 29 Sep, 2022
Improve Article
Save Article

Construct a DFA for a language accepting strings of length at least two, over input alphabets Σ = {0,1}. So that means in DFA, language consists of a string of length of at least 2 and can be greater than two. That means if DFA got the string of Length 0 or 1 then it will not accept it. A string of length zero means when the machine doesn’t get any symbol as an input.

Approach: 

  • First, try to make the language with the help of string conditions. 
  • Find the minimum possible string that satisfies the condition of the length of at least two.
  • So, the required strings with lengths of 2 and more will be the strings in the given language.

Concept:

We need a language that will accept a string of length of at least 2 and can be greater than 2. So that means strings with lengths zero and one, will not be part of the language but apart from that, every string can be accepted by a given language. So firstly we will make DFA for the minimum string here of length 2 and then later, we don’t have any restrictions of input alphabets a and b so we will accept everything with any sequence.

Let’s discuss the stepwise construction of DFA:

Steps for Construction: 

Accepting minimum string of length 2: We need a DFA which will accept strings of length two. So for that, we’ll make an initial state for DFA named q0 followed by two states q1 and q2 which will be able to accept a string of length of exactly 2. 

Initializing the start state and conventions for states

Now see the DFA which will accept the string of length exact two:

 

Accepting string of length at least two: Above DFA don’t have any transition for a and b. So according to the given language, we need a string with a length of two and more than that, so we are done with a minimum string of length 2. For string that has a length greater than 2. We need a self-loop on state q2 for input alphabets a and b. So it can be capable of generating a string of length greater than two.

 

This is the final DFA which is capable of accepting strings of length at least two or lengths of two and more than that.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!