# Designing Finite Automata from Regular Expression (Set 5)

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

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

**Regular Expression 1:** Regular language,

L1 = ((a+b)(a+b)(a+b))*

The language of the given RE is,

{aaa, aba, baa, bba}

Length of the string is divisible by 3 ((length of string) mod 3 = 0).

Its finite automata will be like below-

In the above transition diagram, as we can see that initial state ‘W’ on getting either ‘a’ or ‘b’ as the input it transits to a state ‘X’ and so on for the remaining states. Thus this FA accepting all the strings of the given RE language.

**Regular Expression 2:** Regular language,

L2 = (a+b)(a+b).((a+b)(a+b)(a+b))*

The language of the given RE is,

{aa, ab, ba, bb, aaaaa, aabab, ..........}

Length of string mod 3 = 2

Its finite automata will be like below-

In the above transition diagram, as we can see that initial state ‘W’ on getting either ‘a’ or ‘b’ as the input it transits to a state ‘X’ and so on for the remaining states. Thus this FA accepting all the strings of the given RE language.

**Regular Expression 3:** Regular language,

L3 = b*ab*ab*

The language of the given RE is,

{baa, babab, bbabbabb, ......}

Number of ‘a’ exactly 2.

Its finite automata will be like below-

In the above transition diagram, as we can see that initial state ‘W’ on getting ‘b’ as the input it remains in the state of itself and on getting ‘a’ as the input it transits to a state ‘X’ so on for the remaining states. Thus this FA accepting all the strings of the given RE language.

**Regular Expression 4:** Regular language,

L4 = b*ab*a(a+b)*

The language of the given RE is,

{baa, babab, bbabbaabb, ......}

Number of ‘a’ atleast 2.

Its finite automata will be like below-

In the above transition diagram, as we can see that initial state ‘W’ on getting ‘b’ as the input it remains in the state of itself and on getting ‘a’ as the input it transits to a state ‘X’ so on for the remaining states. Thus this FA accepting all the strings of the given RE language.

**Regular Expression 5:** Regular language,

L5 = b*(ε+a)b*(ε+a)b*

The language of the given RE is,

{b, bb, bbb, bab, baab, babab, bbab, .....}

Number of ‘a’ at most 2.

Its finite automata will be like below-

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

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: **DSA Self Paced**. Become industry ready at a student-friendly price.

## Recommended Posts:

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

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.