- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- 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 a DFA recognizing the language {x | the number of 1's is divisible by 2, and 0'sby 3} over an alphabet ∑={0,1}

## Problem

The given language L={ x | the number of 1's is divisible by 2, and 0's by 3} over an alphabet ∑={0,1}.

## Solution

The language is divided into two parts, first we need to find the number of 1’s divisible by 2 and second find out the number of 0’s divisible by 3, finally combine the two parts to generate a result.

**Step 1** − DFA for the first part, number of 1’s divisible by 2.

Here,

q0 on 0 goes to q0 which is a final state, and generates a string 0, accepted by the given language.

q0 on 1 goes to q1, q1 on 1 goes to q0 reaches the final state and generates a string “11” which is divisible by 2.

q0 on 0 goes to q0, q0 on 1 goes to q1, q1 on 0 goes to q1 and q1 on 1goes to q0 which is a final state and generates a string “0101”, which is divisible by 2.

**Step 2** − DFA for the second part, number of 0’s divisible by 3.

Here,

qo’ on 1 goes to q0 which is a final state and generates a string 1, accepted by the language.

q0’ on 0 goes to q1’, q1’ on o goes to q2’ and q2’ on 0 goes to q0’ which is a final state and generates a string “000” which is divisible by 3.

**Step 3** − The final DFA is: DFA first part X DFA second part.

States | 0 | 1 |
---|---|---|

{q0q0’} | {q0q1’} | {q1q0’} |

{q0q1’} | {q0q2’} | {q1q1’} |

{q0q2’} | {q0q0’} | {q1q2’} |

{q1q0’} | {q1q1’} | {q0q0’} |

{q1q1’} | {q1q2’} | {q0q1’} |

{q1q2’} | {q1q0’} | {q0q2’} |

## Transition diagram

The transition diagram for the DFA is as follows −

- Related Questions & Answers
- Construct DFA of alternate 0’s and 1’s
- Construct ∈-NFA of Regular Language L = 0(0+1)*1
- Convert RE 1(0+1)*0 into equivalent DFA.
- Design DFA for language over {0,1} accepting strings with odd number of 1’s and even number of 0’s
- Sum of the Series 1 + x/1 + x^2/2 + x^3/3 + .. + x^n/n in C++
- Sum of the series 1 + (1+2) + (1+2+3) + (1+2+3+4) + ... + (1+2+3+4+...+n) in C++
- Construct ∈-NFA of Regular Language L = (0+1)*(00+ 11)
- Sort an arrays of 0’s, 1’s and 2’s using C++
- Sort an arrays of 0’s, 1’s and 2’s using Java
- Sum of the series 1 / 1 + (1 + 2) / (1 * 2) + (1 + 2 + 3) / (1 * 2 * 3) + … + upto n terms in C++
- Find the nth term of the given series 0, 0, 2, 1, 4, 2, 6, 3, 8, 4… in C++
- Sum of the Series 1/(1*2) + 1/(2*3) + 1/(3*4) + 1/(4*5) + ... in C++
- Construct a Turing Machine for language L = {wwr | w ∈ {0, 1}}
- Construct a TM recognizing strings of the form an bn cn| n≥1 over = {a, b, c}
- Sum of the series 2^0 + 2^1 + 2^2 +...+ 2^n in C++