# Designing Finite Automata from Regular Expression (Set 3)

Prerequisite: Finite automata, Regular expressions, grammar and language, Designing finite automata from Regular expression (Set 2)

In the below article, we shall see some Designing of Finite Automata form the given Regular Expression.

**Regular Expression 1:** ‘ab*’ (‘a’ followed by any number of ‘b’). The language of the given RE is,

L1 = {a, ab, abb, abbb, .........}

Its finite automata will be like below-

In the above transition diagram, as we can see that state ‘X’ on getting ‘a’ as the input it transits to a final state ‘Y’ which on getting ‘b’ as the input it remains in the state of itself. Thus this FA accepting all the strings of the given RE language.

**Regular Expression 2:** ‘(ab)*’ (‘a’ followed by ‘b’ but substring ‘ab’ can be repeated any number of times). The language of the given RE is,

L2 = {ε, ab, abab, ababab, .........}

Its finite automata will be like below-

In the above transition diagram, as we can see that initial and final state ‘X’ on getting ‘a’ as the input it transits to a final state ‘Y’ which on getting ‘b’ as the input it comes back to the state ‘X’. Thus this FA accepting all the strings of the given RE language.

**Regular Expression 3:** ‘(a+b)*’ (‘a’ union ‘b’ but substring ‘a+b’ can be repeated any number of times). The language of the given RE is,

L3 = {ε, a, b, aa, aaab, bbbbb, ba, .......}

The language containing ε and any number of ‘a’ or ‘b’ or both combined.

Its finite automata will be like below-

In the above transition diagram, as we can see that state ‘X’ on getting ‘a’ as the input it remains in the state of itself and on getting ‘b’ as the input it transits to an another final state ‘Y’ which on getting ‘b’ or ‘a’ as the input it remains in the state of itself. Thus this FA accepting all the strings of the given RE language.

**Note –** The minimal DFA of regular expression (a+b)* will have only single state, which is both starting and final state. This will contain only loop of alphabet ‘a’ and ‘b’.

**Regular Expression 4:** ‘(ab+ba)*’ (‘ab’ union ‘ba’ but substring ‘ab+ba’ can be repeated any number of times). The language of the given RE is,

L4 = {ε, ab, abab, abba, ba, baba, ........ }

The language containing ε and any number of ‘ab’ or ‘ba’ or both combined.

Its finite automata will be like below-

In the above transition diagram, the initial and final state ‘X’ on getting ‘a’ as input it go to a state ‘Y’ and on getting ‘b’ as the input it go to an another state ‘Z’ and so on for the remaining states. Thus this FA accepting all the strings of the given RE language.

**Regular Expression 5:** ‘a+’ (Any number of ‘a’ excluding ε).

The language of the given RE is

L5 = {a, aa, aaa, aaaa, .........}

Its finite automata will be like below-

In the above transition diagram, initial state ‘X’ on getting ‘a’ as the input it transits to a final state ‘Y’ which on getting ‘a’ as the input it remains in the state of itself. Thus this FA accepting all the strings of the given RE language.

## Recommended Posts:

- Designing Finite Automata from Regular Expression (Set 4)
- Designing Finite Automata from Regular Expression (Set 2)
- Designing Finite Automata from Regular Expression (Set 1)
- Designing Finite Automata from Regular Expression (Set 8)
- Designing Finite Automata from Regular Expression (Set 6)
- Designing Finite Automata from Regular Expression (Set 7)
- Designing Finite Automata from Regular Expression (Set 5)
- Generating regular expression from Finite Automata
- Designing Deterministic Finite Automata (Set 10)
- Designing Deterministic Finite Automata (Set 11)
- Designing Non-Deterministic Finite Automata (Set 3)
- Designing Non-Deterministic Finite Automata (Set 4)
- Designing Non-Deterministic Finite Automata (Set 1)
- Designing Non-Deterministic Finite Automata (Set 5)
- Designing Deterministic Finite Automata (Set 2)

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.