- Related Questions & Answers
- Check If All 1's Are at Least Length K Places Away in C++
- Construct DFA with Σ= {0,1} accepts all strings with 0.
- Sum of the series 2^0 + 2^1 + 2^2 +...+ 2^n in C++
- Maximum length subsequence with difference between adjacent elements as either 0 or 1 | Set 2 in C++
- Forming string using 0 and 1 in JavaScript
- Maximum length of segments of 0’s and 1’s in C++
- Find all the patterns of “1(0+)1” in a given string in C++
- Program to find length of longest substring with character count of at least k in Python
- Sum of series 1^2 + 3^2 + 5^2 + . . . + (2*n – 1)^2
- Sum of the series 1 / 1 + (1 + 2) / (1 * 2) + (1 + 2 + 3) / (1 * 2 * 3) + … + upto n terms in C++
- Find all the patterns of “1(0+)1” in a given string using Python Regex
- Contiguous subarray with 0 and 1 in JavaScript
- Find the number of binary strings of length N with at least 3 consecutive 1s in C++
- Program to find length of longest increasing subsequence with at least k odd values in Python
- Sum of the series 1 + (1+2) + (1+2+3) + (1+2+3+4) + ... + (1+2+3+4+...+n) in C++

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Non-deterministic finite automata also have five states which are same as DFA, but with different transition function, as shown follows −

δ: Q X Σ -> 2Q

Non-deterministic finite automata is defined as a 5 tuple,

**M=(Q, Σ, δ,q0,F)**

Where,

- Q: Finite set of states
- Σ: Finite set of the input symbol
- q0: Initial state
- F: Final state
- δ: Transition function: Q X Σ -> 2Q

Design a transition diagram and table for the given language that accepts all strings of length at least 2.

Before proceeding to the solution, let’s understand what do you mean by length of string and how to find the length of any string.

The **length of a string** means it is the number of symbols in the string or word. It is denoted by |w|.

For Example: w=01011001 from binary alphabet Σ={0,1}

|w| = 8

In a given problem, the strings should have length of at least 2. That is, the length should be 2 or more, but not less than 2 over the alphabet Σ = {0, 1}.

The language L= { 00,01,10,11,001,110,101,111,000,1101,0010,…….}

The transition diagram of NFA for the given language is −

The transition table is as follows −

Present state | Next state for input 0 | Next state for input 1 |
---|---|---|

->q0 | q1 | q1 |

q1 | q2 | q2 |

*q2 | ε | ε |

**Step 1**− q0 is an initial state on input ‘0’ it goes to state q1 and on input ‘1’ goes to state q1.**Step 2**− q1 is an intermediate state on input ‘0’ and ‘1’ goes to state q2.**Step 3**− q2 is the final state, it contains epsilon transitions.

Construct an NFA with Σ = {0, 1} which accepts all string ending with 01.

In a given problem, the language accepts all strings ending with 01.

The language L= { 01,101,1101,001,11001,0101,11101,0001,1001,00101,…….}

The transition diagram is as follows −

The transition table is as follows −

Present state | Next state for input 0 | Next state for input 1 |
---|---|---|

->q0 | q0,q1 | q0 |

q1 | - | q2 |

*q2 | - | - |

**Step 1**− q0 is an initial state on input ‘0’ ii goes to multiple states q0 and q1 and ‘1’ it goes to state q0 itself.**Step 2**− q1 is an intermediate state on input ‘1’ goes to state q2.**Step 3**− q2 is the final state, it contains epsilon transitions.

Advertisements