- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Construct an NFA accepting strings with an even number of 0s or an odd number of 1s
Non-deterministic finite automata (NFA) also have five states which are same as DFA, but with different transition function, as shown follows −
δ: Q X Σ → 2Q
Where,
- Q : Finite set called states.
- Σ : Finite set called alphabets.
- δ : Q × Σ → Q is the transition function.
- q0 ϵ Q is the start or initial state.
- F : Final or accept state.
Problem
Construct NFA over an alphabet Σ={0,1}.
Solution
Design two separate machines for the two conditions, as given below −
NFA accepting only odd number of 1’s
NFA accepting only even number of 0’s
NFA accepting only odd number of 1’s over an alphabet Σ= {0,1}.
The language it generates is −
L={1,111,01,001,0111,0010,01110,….}
State o1 on 0 goes to o1 and on 1 goes to state o2.
State o2 on 0 goes to o2 and on 1 goes to o1.
NFA Accepting only even number of 0’s over an alphabet Σ= {0,1}
The language it generates is −
L={100,1100,1010,1100010,…….}
State E1 on 1 goes to E1 and on 0 goes to E2.
State E2 on 1 goes to E2 only and on 0 goes to E1.
Now merge the two transition diagrams with an epsilon move.
The NFA that accepts all strings with an even number of 0s or an odd number of 1s is as follows −
- Related Articles
- C Program to construct DFA accepting odd numbers of 0s and 1s
- Design DFA for language over {0,1} accepting strings with odd number of 1’s and even number of 0’s
- Every even number is followed by an odd number and every odd number is followed by an even number. What is the meaning ?
- Count number of even and odd elements in an array in C++
- Largest subarray with equal number of 0s and 1s in C++
- Examine each of the following statements and comment: If a die is thrown once, there are two possible outcomes -an odd number or an even number. Therefore, the probability of obtaining an odd number is \( \frac{1}{2} \) and the probability of obtaining an even number is \( \frac{1}{2} . \)
- Count Substrings with equal number of 0s, 1s and 2s in C++
- Java program to Print Odd and Even Number from an Array
- Which of the following arguments are correct and which are not correct? Give reasons for your answer.If a die is thrown, there are two possible outcomes- an odd number or an even number. Therefore, the probability of getting an odd number is $\frac{1}{2}$.
- Splitting number to contain continuous odd or even number using JavaScript
- Design a DFA machine accepting odd numbers of 0’s or even numbers of 1’s
- Express the sum of 9 as an odd consecutive number.
- Encoding a number string into a string of 0s and 1s in JavaScript
- C++ Queries on Probability of Even or Odd Number in Given Ranges
- PHP program to check if the total number of divisors of a number is even or odd
