Deterministic Finite Automata (DFA) is defined as an abstract mathematical concept which is used to solve various specific problems in different software and hardware.In this type of problems we have some given perimeters according to which we should design DFA.

In this article,two instructions are given:

- DFA should have one of a
- DFA should have at least one b

This DFA should accept the strings such as **ab, ba, abb, bab, bba, abbb, babb, bbab, bbba, abbbb…. **etc but it should not accept string such as **a, b, bb, bbb, aabb, ababa…** etc.

**Designing step-by-step :**

**Step-1:**

Take a initial state A,and smallest possible string are ab and ba, if A takes ‘a’ as first input alphabet it goes to state B and if A takes ‘b’ as first input alphabet it goes to state C.

**Step-2:**

Now think about state B, if it takes input alphabet ‘a’,it breaks our condition of only one ‘a’ but if takes input alphabet ‘b’ it makes a acceptable string and now it goes to state D which is set to final state.

**Step-3:**

On state C if it can take any numbers of ‘b’ which is possible and it can also take ‘a’ as input alphabet.On alphabet ‘b’ it remains on same state but on input ‘a’ it goes to state E which will set to final state.

**Step-4:**

Input alphabet ‘a’ of state B breaks the condition so it goes to some dead state(Q).

**Step-5:**

Till now, our machine accepts string which are end from ‘a’ and ‘ab’.But what about if ‘a’ comes in middle such as bab,babb,bbab etc and what if there are many ‘b’ in the end.To do that give self loop of ‘b’ to both final stat and send their ‘a’ to dead state.

**Note –**

Input alphabets of dead state is going to dead state only that is why these are not showing in diagrams.

Transition Table and Transition Rules of above diagram.

finite set of states = {A, B, C, D, E, Q}

In transition table initial state is represented by → and the final state are E and D.

set of input alphabets = {a, b}

STATE | INPUT (a) | INPUT (b) |
---|---|---|

→A | B | C |

B | Q (dead state) | D |

C | E | C |

D | Q (dead state) | D |

E | Q (dead state) | E |

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

## Recommended Posts:

- DFA of a string with at least two 0’s and at least two 1’s
- DFA in LEX code which accepts even number of zeros and even number of ones
- DFA machines accepting odd number of 0’s or/and even number of 1’s
- DFA for strings not containing consecutive two a's and starting with 'a'
- Construct a DFA which accept the language L = {w | w ∈ {a,b}* and Na(w) mod 3 = Nb (w) mod 3}
- Program to build a DFA that accepts strings starting and ending with different character
- Program to build a DFA to accept strings that start and end with same character
- Difference between DFA and NFA
- Build a DFA to accept a binary string containing "01" i times and "1" 2j times
- Design a DFA that accepts a string containing 3 a's and 3 b's
- DFA of alternate 0's and 1's
- Conversion from NFA to DFA
- Minimization of DFA
- DFA for accepting the language L = { a
^{n}b^{m}| n+m=even } - Program to Implement NFA with epsilon move to DFA Conversion
- DFA for Strings not ending with "THE"
- Union process in DFA
- Concatenation process in DFA
- Complementation process in DFA
- DFA of a string in which 2nd symbol from RHS is 'a'

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.